This is what I've learned in this semester. In Digital Image Processing class, my lecturer gave me a very strange image. Let me show you the image..
Real Image |
Ok, now what to do with this image? My lecturer said that maybe he'll use this image in the final examination. I've heard that last semester, the same lecturer gave this picture too in the final examination. The main goal is to remove the noise from the image, and then manipulate the object in the image so that the rubber band will have a red color and the other solid objects will have a green color, using Matlab. I've trying to do it several hours ago using Matlab, and the result is.... Yes, I can! Here is my Matlab script to manipulate the image above:
%read the image a=imread('imagefile'); %convert to black and white b=im2bw(a); %filter small noise for i = 1:6 b = medfilt2(b); end %give label for each object + count all object [L,n] = bwlabel(b); %next? specify the Euler number of each object filt=regionprops(L,'eulernumber'); %define the RGB matrix with the same size of the main image R=zeros(size(b)); G=zeros(size(b)); B=zeros(size(b)); %based on Euler number of each object.. %..we can give the color of each object for i=1:n if (filt(i).EulerNumber==0) R=R|uint8(L==i)*255; else G=G|uint8(L==i)*255; end end %last, create 3 dimentional matrix and preview it! imshow(cat(3,R,G,B));
If everything is ok, the result of the code above will manipulate the strange image into something different. Just try it :)
Processed image |
And finally! If you don't understand the code above, please refer to Matlab product help. Thank you for reading this post :)
No comments:
Post a Comment