% These are commands you can use in order to test the different region % based segmentation algorithms. Paste them in the Matlab command window % and things should work. % Test the merging algorithm % Clear everything clear all close all % Go to your image catalog and read your image (exchange with your own % catalog) cd 'C:\Documents and Settings\aurdal\My Courses\UIO\INF3300' i=double(imread('apple1.tif')); %i=double(rgb2gray(imread('mm3.tif'))); % Take a look at the image figure imshow(i,[min(min(i)) max(max(i))]) % Make initial suggestion for segmented image tmp_seg=reshape(1:prod(size(i)),size(i)); % Test elementary region growing on this image. Try changing the value % for the criterion and the connectivity. And obviously, try different % images. [seg,seg_arr,reg]=region_grow1(i,tmp_seg,25,8); % Take a look at the result map=rand(max(max(seg)),3); figure imshow(seg,[]) colormap(map) % Test the splitting algorithm % Clear everything clear all close all % Go to your image catalog and read your image (exchange with your own % catalog) cd 'C:\Documents and Settings\aurdal\My Courses\UIO\INF3300' i=double(imread('apple1.tif')); % Take a look at the image figure imshow(i,[min(min(i)) max(max(i))]) % Test elementary region splitting on this image. Try changing the value % for the criterion. And obviously, try different % images. [seg,dummy,c_lab]=region_split1(i,10,1,[]); % Take a look at the result map=rand(max(max(seg)),3); figure imshow(seg,[]) colormap(map) % Test the split and merge algorithm % Clear everything clear all close all % Go to your image catalog and read your image (exchange with your own % catalog) cd 'C:\Documents and Settings\aurdal\My Courses\UIO\INF3300' i=double(imread('apple1.tif')); % Take a look at the image figure imshow(i,[min(min(i)) max(max(i))]) % Run elementary region splitting on this image [seg,seg_val,c_lab]=region_split1(i,10,1,[]); % Take a look at the result map=rand(max(max(seg)),3); figure imshow(seg,[]) colormap(map) % Run elementary region growing on the image seg_val with the split % segmentation as initial segmentation [seg2,seg_arr,reg]=region_grow1(i,seg,5,8); % Take a look at the result map=rand(max(max(seg2)),3); figure imshow(seg2,[]) colormap(map) % Test if the order of region merging is unimportant using the merging algorithm % Clear everything clear all close all % Go to your image catalog and read your image (exchange with your own % catalog) cd 'C:\Documents and Settings\aurdal\My Courses\UIO\INF3300' i=double(imread('apple1.tif')); %i=double(rgb2gray(imread('mm3.tif'))); % Take a look at the image figure imshow(i,[min(min(i)) max(max(i))]) % Make an initial suggestion for the segmented image tmp_seg=reshape(1:prod(size(i)),size(i)); % Test elementary region growing on this image and on its trnspose. Try changing the value % for the criterion and the connectivity. And obviously, try different % images. [seg1,seg_arr,reg]=region_grow1(i,tmp_seg,25,8); [seg2,seg_arr,reg]=region_grow1(flipud(i),tmp_seg,25,8); % Take a look at the result map=rand(max(max(seg1)),3); figure imshow(seg1,[]) colormap(map) map=rand(max(max(seg2')),3); figure imshow(flipud(seg2),[]) colormap(map)