Hi,
This is my first task using Matlab.
I'm hoping to analyze the percentage dark area in my greyscale image. How can I mask some undesired regions in the image before making binary images for area calculation? Below is my code which didn't work
imdir = 'C:\Users\wkuo7\Documents\MATLAB\';imfile1 = '1103.tif';I1 = imread([imdir, imfile1]);I2=imshow(I1);I3 = roipoly; %and then I draw an ROI and right click to create mask%
I4=imshow(I3); % at here I saw binary image of my ROI (white) and rest (dark)%
H = fspecial('unsharp');I5 = roifilt2(H,I2,I4);figure, imshow(I5) %at here I saw figure window pop up, but no image.
below is the code which worked to give me the percentage dark area, but this one has no masking yet.
imdir = 'C:\Users\wkuo7\Documents\MATLAB\';imfile1 = '1103.tif';I1 = imread([imdir, imfile1]);I2 = imcrop(I1,[1 1 1424 845]);BW1 = roicolor(I2,0,1000); BW2 = roicolor(I2,100,1000); imshow(BW2);percentage = 1 - bwarea(BW2)/bwarea(BW1)
Thank you very much!
Best Answer