slim: simple language for image manipulation. bardhi shtylla team manager

28
SLIM: Simple Language for Image Manipulation

Upload: leslie-cummings

Post on 17-Dec-2015

226 views

Category:

Documents


1 download

TRANSCRIPT

SLIM:Simple Language for Image

Manipulation

Bardhi ShtyllaTeam Manager

What it is

Slim is a scripting language that makes image manipulation easy.

It works with the following image files: .jpg, .gif, .png, .tiff, .bmp, .tga

What it does

Slim works with a version of GIMP

(GNU Image Manipulation

Program) it makes possible the

usage of simple functions to make

complicated image changes.

What it does

For instance, to concatenate

horizontally two images, $i1

and $i2, into the result, $i3, all

the necessary command in

SLIM is:

$i3 = $i1 +_ $i2;

Properties

3 basic types: •num (equivalent to a float)•string (a sequence of characters)•image (contains a GIMP image)

PropertiesOperations (all non-destructive):•Simple arithmetic operations among num-s.•String concatenation•Image operations such as:Cropping, Concatenation, Scaling, Rotation, Contrast, etc.

Sample ProgramSample Program

image $img1, $img2, $img3img3;$img1 = “img_file.jpg”;#/rotate 90 degrees counter-clockwise$img2 = $img1 @ -90; #concatenate horizontally into $img3$img3 = $img1 +_ $img2;

Development environment and support tools used

Benny Wong

Development Environment

• LEX and YACC– More control– Comfortable– GIMP

• LINUX Coding environment• CVS

Support Tools

• Development– CVS

• Communication– Wiki– Ultimately, email communication– Meetings

Language Architecture Chad Plummer

Architecture Diagram

Lex (Flex)

Source Code

Yacc (Bison)Tokens

Tree Walker:C Code

ASTSymbol Table

Hash Lookups

The GIMP Scheme

Inter-Process Communication

File I/O Standard Out

Sample Program#sample.slimnum $n; #Declarationstring $s;

$n = 0;image $i[$n + 2]; #Must be run-time declared

loop($n < 2 ) { #The next two lines have type promotion/coercion $i[$n] = “a” . $n . “.jpg” +_ “b”. $n . “.jpg”; $s = $n; save $i[n], “out” . $s . “.jpg”; $n = $n + 1;}

Testing SLIM Michael Wasserman

Test Plan

•Lexical•Grammar and IR Structure•Code and Error Reporting•Regression

Test Plan

Lexical: #define lex_printout 0/1…

if { if( lex_printout ) printf("<Read IF>"); yylval.op = IF; return IF;}

else { if( lex_printout ) printf("<Read ELSE>"); yylval.op = ELSE; return ELSE;}

loop { if( lex_printout ) printf("<Read LOOP>");yylval.op = LOOP; return LOOP;}

width { if( lex_printout ) printf("<Read WIDTH>"); yylval.op = WIDTH; return WIDTH;}

height { if( lex_printout ) printf("<Read HEIGHT>"); yylval.op = HEIGHT; return HEIGHT;}

length { if( lex_printout ) printf("<Read LENGTH>"); yylval.op = LENGTH; return LENGTH;}

random { if( lex_printout ) printf("<Read RANDOM>"); yylval.op = RANDOM; return RANDOM;}

blank { if( lex_printout ) printf("<Read BLANK>"); yylval.op = BLANK; return BLANK;}

num { if( lex_printout ) printf("<Read NUM TYPE>"); yylval.op = NUM; return DATA;}

string { if( lex_printout ) printf("<Read STR TYPE>"); yylval.op = STR; return DATA;}

image { if( lex_printout ) printf("<Read IMG TYPE>"); yylval.op = IMG; return DATA;}

{id} { if( lex_printout ) printf("<Read ID>"); yylval.str = strdup( yytext );return IDENTIFIER; }

Test Plan

Grammatical: #define lex_printout 0/1

IR Structure: #define graph_printout…

expression: l_value ASSGN expression {$$ = Node_new_binaryop( $1, $3, $2 );if( yacc_printout ) printf( "LVAL=EXPR -> EXPR\n" );if( graph_printout ) Node_draw( fpg, $$ );

}| expression ASSGN expression {

$$ = Node_new( Item_new( TYPE_ERR ) );Node_set_Item_str( $$, "expression = expression" );printerr( "Semantic error, cannot assign value to an expression." );if( yacc_printout ) printf( "ERROR: EXPR = EXPR -> EXPR\n" );if( graph_printout ) Node_draw( fpg, $$ );

}| expression OR expression {

$$ = Node_new_binaryop( $1, $3, $2 );if( yacc_printout ) printf( "EXPR||EXPR -> EXPR\n" );

if( graph_printout ) Node_draw( fpg, $$ );}

Test PlanIR Structure: DOT & graphs (Semantic checking)

digraph S {graph [bgcolor=azure2]ranksep=.2;0 [label="NULL",shape=none,fontsize=12,height=.2];1 [label="START",shape=none,fontsize=12,height=.2];2 [label="END",shape=none,fontsize=12,height=.2];node [shape=ellipse,fontsize=10,height=.2];1104770710 [label="$a",shape=hexagon,color=green];1104771060 [label="$b",shape=hexagon,color=green];1104771210 [label="$c",shape=hexagon,color=green];1104771340 [label="$d",shape=hexagon,color=green];1104771470 [label="$w",shape=hexagon,color=green];1104771620 [label="$h",shape=hexagon,color=green];1104771710 [label="NUM $a ",shape=house,color=brown];1104771710 -> 1104770710 [color=green];…

#Guillotine - Mike Wasserman#SLIM Tutorial Program#3/26/06

# This tutorial program illustrates several important concepts while performing a task.# The task is to split each image within a set of images into 4 quardants using the concatenation operator.

# Listing variable declarations at the top of the program is not necessary, but it is good practicenum $a, $b, $c, $d, $w, $h;string $s;image $i;

# You should print a quick description of your program to the userprint "Welcome to Guillotine, this will split {0.jpg, 1.jpg,...,9.jpg} into qaudrants {q1, q2, q3, q4}.";

# Initialize variables that a requisite for loop conditional testing before invoking loop$a = 0;…

mike_tutorial.slim

mike_tutorial.DOT

mike_tutorial.gif

Test Plan

•Error Reporting–program suite, manual

•Regression:–lex_test_suite.slim–program suite

•Resources:•TUTORIAL PROGRAMS,

•ASSEMBLED PROGRAMS,

•BROKEN FEATURE INVESTIGATORS

•PRODUCED IMAGES

Conclusion Jonathan Uy

Why SLIM?

It is usually very complicated to do image manipulation with most mainstream languages.

By adopting a syntax similar to that of C and making it possible to do complicated functions with a few simple commands, SLIM completely solves the problem.

Why use SLIM?

• Makes image manipulation extremely easy.

Example of saturation in C++:Example of saturation in C++:

Why use SLIM?Example of saturation in SLIM:Example of saturation in SLIM:

$pic = $pic ~ $factor;$pic = $pic ~ $factor;

Concluding Reflections• What worked well• What we learned• What we would have done differently

What We’ve Learned

• Communication is key• Clear set goals

– Timelining– Hard deadlines

• Second pair of eyes help a lot• Realistic goals – second opinion

Thank You!