Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32MATLIP: MATLAB-Like Language for Image ProcessingPin-Chin Huang ([email protected])Shariar Zaber Kazi ([email protected])Shih-Hao Liao ([email protected])PoHsu Yeh ([email protected])Motivation•Easy to codeEasy to access pixels of an imageEasy to do image arithmetic operationEasy to do image convolutionEasy to assign images of any sizeEasy to debug•No cost for license•Good PortabilityEasy to access one pixel of an imagefunction = main() image x; x=imread("./rabbit.jpg"); print(x[1,1,"RGB"]);endpublic static void main(String[] args){BufferedImage x = imnew(100, 100, "RGB");x = imread("./rabbit.jpg");System.out.println(getImagePixel(x, 1, 1, "RGB"));}static int getImagePixel(BufferedImage im, int col, int row, String channel){…………………………}26 lines of java codeEasy to do image arithmetic operationfunction = main() image x; image y; x=x+1; x=x-1; x=x*1; x=x/1; x=x+y;endpublic static void main(String[] args){BufferedImage x = imnew(100, 100, "RGB");BufferedImage y = imnew(100, 100, "RGB");x = imread("./rabbit.jpg");x = (BufferedImage)clone((BufferedImage)doArithmetic(x, 1, OPERATION.ADD));x = (BufferedImage)clone((BufferedImage)doArithmetic(x, 1, OPERATION.SUB));x = (BufferedImage)clone((BufferedImage)doArithmetic(x, 1, OPERATION.MUL));x = (BufferedImage)clone((BufferedImage)doArithmetic(x, 1, OPERATION.DIV));x = (BufferedImage)clone((BufferedImage)doArithmetic(x, y, OPERATION.ADD));}static Object doArithmetic(Object op1, Object op2, OPERATION op){……………}static Object clone(Object src){……………………}150 lines of java codeEasy to do image convolutionfunction = main() image x; kernel k; x=x@k;endpublic static void main(String[] args){BufferedImage x = imnew(100, 100, "RGB");Kernel k = kernelinit();x = (BufferedImage)clone(convolve(x, k));}static BufferedImage convolve(BufferedImage im, Kernel k){………………….}static Object clone(Object src){…………………….}45 lines of java codeEasy to assign image to image of different sizefunction = main() image a; image b; a = imnew(300,300,"RGB"); b = imnew(200,200,"RGB"); a=b; endpublic static void main(String[] args){BufferedImage a = imnew(100, 100, "RGB");BufferedImage b = imnew(100, 100, "RGB");a = imnew(300, 300, "RGB");b = imnew(200, 200, "RGB");a = (BufferedImage)clone(b); }static BufferedImage imnew(int width, int height, String type){…………..}static Object clone(Object src){………………………}50 lines of java codeEasy to debugfunction = main() int i; for i=0:(int y):100 x=x+1; end y=0;endsyntax error in line #3Fatal error: exception Parsing.Parse_errorFatal error: exception Failure("Type mismatch in argument passing between: 'x', type: int and 'x', type: float in function: 'test'“)function int m = test (int x) endfunction = main () float x; x=1.0; test(x);endEasy to debugfunction int m = test () endfunction = main () int x; x=1; test(x);endFatal error: exception Failure(“Wrong number of arguments passed to function: ‘test’”)Fatal error: exception Failure("Cannot concatenate image type with string type in function: 'main'")function = main() image x; imshow(x); x = imread("./rabbit.jpg"+x); imshow(x); imsave(x,"./rabbit.jpg"); x = imnew(300,300,"RGB"); imshow(x);endNo cost for licenseImage Processing Toolbox 6.2 (MATLAP)•Individual LicenseFor: End userActivation types: Standalone named user or designated computer•$1,000•BuyRequest a Quote (via fax or e-mail)Contact Sales•For an end user who wants to personally install, administer, and operate the software.•Group License For: WorkgroupActivation Types: Standalone named users or designated computers•Request a Quote (via fax or e-mail)Contact Sales•For organizations who would like to designate an administrator to manage a group of Individual licenses.Tutorial introduction•Variable declaration and assignment:int a;float b;boolean c;kernel k;image i;function = main()a=1;b=0.1;c=true;k=kernelnew(10,10);k=[0.0,0.1;0.3,0.4];i=imnew(10,10,”RGB”);end int a=3;float b=0.3;boolean c =true;Kernel k=kernelnew(10,10);Image i=imnew(10,10,”RGB”);Arithmetic OperationInt a;Int b;float c;float d;funciton = main()a=a+b;a=a-b;a=a*b;a=a/b;a=a^b;a=mod(a,b);c=c+d;c=c-d;c=c*d;c=c/d;endimage a;image b;int c;function =main()a=a+b;a=a-b;a=a*b;a=a/b;a=a*2+b;a=a*c+b;a=a*2.0; (NOT OK)a=2*a;(NOT OK)endkernel k1;kernel k2;float a;function = main()k1=k1+k2;k1=k1-k2;k1=k1*k2;k1=k1/k2;k1=k1*2.0+k2;k1=k1*a+k2;k1=k1*2+k2;(NOT OK)k1=2.0*k1+k2;(NOT OK)endControl Flow Statementint x;function=main()x=1;If x==1 x=x+1;elseif x==2 x=x+2;elseif x==3 x=x+3;else x=x+4;endendint x;funciton=main()x=1;If x==1 x=x+1;endendInt x;function=main()x=1;if x==1x=x+1;elseif x==2x=x+2;endInt x;function=main()x=1;if x==1x=x+1;else x=x+2;endControl Flow Statementfunction = main()int x;int i;for i=0:1:10 x=x+1;endendfunction = main()Int x;while x<3 x=x+1;endendFunctionfunction = test()end function main()test();endfunction main()Int d;d=test();Endfunction int m= test()end function int m= test(int x) m=d;end function main()Int d;d=test(d);endRecursionfunction int m = foo (int x) if(x > 0) m=foo(x-1); else m=-1; endendfunction int m = bar (int x) m=x+1;endfunction = main() print(foo(bar(foo(5))));endExample (Flip the image vertically)Example (Flip the image vertically)function image ret = flip(image im)int height;int width;int i;int j;height = getheight(im);width = getwidth(im);ret=imnew(width,height,"RGB");for j=0:height-1 for i=0:width-1 ret[i,height-j-1,"rgb"]=im[i,j,"rgb"]; endendendfunction = main() image x; image y; x=imread("./rabbit.jpg"); imshow(x); y=flip(x); imshow(y); endExample (Flip the image vertically)Example (Flip the image horizontally)function image ret = flip(image im) int height; int width; int i; int j; height = getheight(im); width = getwidth(im); ret=imnew(width,height,"RGB"); for j=0:height-1 for i=0:width-1 ret[width-i-1,j,"rgb"] = im[i,j,"rgb"]; end endendfunction = main() image x; image y; x=imread("./rabbit.jpg"); imshow(x); y=flip(x); imshow(y);endExample (Flip the image
View Full Document