Click here to Skip to main content
15,867,860 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The output i get is black image . Why ? Which part is incorrect?

What I have tried:

i=imread('flair.jpg');
[m,n]=size(i);
i2 = zeros(size(i));
for y =1:m
    for x=1:n
        if i(y,x) >= 0.2 && i(y,x) <= 0.7
            i2(y,x) = 1;
        end
    end
end
figure;
imshow(i2), title("Double Tresholding Segmentation");
Posted
Updated 27-Jun-22 22:05pm
Comments
Richard MacCutchan 28-Jun-22 4:02am    
Check the values in the original image. I suspect that the values you are testing against are not in the source matrix.

1 solution

Add this line
i1 = im2double(i); as the third line. Then modify your if loop to handle i1.

The image is an 8-bit image, having values from 0 to 255, and there are no values in the range 0.2 to 0.7. You need to convert it to a double image, within the range 0 to 1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900