geom1
Contents
clear close all rgb = imread('kodim04.png'); imshow(rgb);
Warning: Image is too big to fit on screen; displaying at 67%
imtranslate
out = imtranslate(rgb,[50 20]); imshow(out);
Warning: Image is too big to fit on screen; displaying at 67%
out = imtranslate(rgb,[100 200],'FillValues',[255 255 0]);
imshow(out);
Warning: Image is too big to fit on screen; displaying at 67%
out = imtranslate(rgb,[100 -100],'OutputView','full'); imshow(out); size(rgb) size(out)
Warning: Image is too big to fit on screen; displaying at 67% ans = 768 512 3 ans = 868 612 3
explore fractional pixel translation with a 5 x 5 matrix
% original img = zeros(5); img(3,3)=1 imshow(imresize(img,16,'nearest'));
img = 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
% translated out = imtranslate(img,[0.5 0.6]); imshow(imresize(out,16,'nearest')); out
out = 0 0 0 0 0 0 0 0 0 0 0 0 0.2000 0.2000 0 0 0 0.3000 0.3000 0 0 0 0 0 0
% translated back out2 = imtranslate(out,[-0.5 -0.6]); imshow(imresize(out2,16,'nearest')); out2
out2 = 0 0 0 0 0 0 0.0600 0.1200 0.0600 0 0 0.1300 0.2600 0.1300 0 0 0.0600 0.1200 0.0600 0 0 0 0 0 0
imresize example
out = imresize(rgb,[900 300]); imshow(out);
Warning: Image is too big to fit on screen; displaying at 67%
imrotate
out = imrotate(rgb,15); imshow(out); size(rgb) size(out)
Warning: Image is too big to fit on screen; displaying at 67% ans = 768 512 3 ans = 877 697 3
out = imrotate(rgb,15,'crop');
imshow(out)
Warning: Image is too big to fit on screen; displaying at 67%
out2 = imrotate(out,-15,'crop');
imshow(out2)
Warning: Image is too big to fit on screen; displaying at 67%
% compare before and after do_input = false; if do_input [c2, rect] = imcrop(out2); else rect = [88 88 338 536]; c2 = imcrop(out2,rect); end c1 = imcrop(rgb,rect); diff = rgb2gray(im2double(c2)) - rgb2gray(im2double(c1)); imshow((4*diff+1)/2); figure imhist((diff+1)/2);
other operations
g = rgb2gray(im2double(rgb)); close all imshow(g); title('original image'); gf = fliplr(g); figure imshow(gf); title('after fliplr');
Warning: Image is too big to fit on screen; displaying at 67% Warning: Image is too big to fit on screen; displaying at 67%
gf = flipud(g); imshow(gf);
Warning: Image is too big to fit on screen; displaying at 67%
gf = g'; imshow(gf);
gf = rot90(g); imshow(gf);