How can i modify matrix which i retrieve from image?

I have a gray image, i want to see only the black part ,rest of image i want to replace with value 250, so that gray part will be white.
f=imread('image1.jpg');
T = zeros(size(f));
for ii = 1:numel(f)
if f(ii)<50
T(ii) = f(ii);
else
T(ii) = 250;
end
end
imshow(T)

5 commentaires

Matt J
Matt J le 19 Juin 2013
Yes, the code you've shown would accomplish that, so what is your question?
Iain
Iain le 19 Juin 2013
What, exactly, is your question?
when i want to see the image(T), it's blank or whole image is white.
Evan
Evan le 19 Juin 2013
What's the minimum value of your image?
40

Connectez-vous pour commenter.

 Réponse acceptée

Iain
Iain le 19 Juin 2013
Try:
%if the problem is just the data type, this should work:
T = f;
T(T>50) = 255;
If the problem is that you can't see the very few black pixels, tell us the result from
sum(f(:) <51)

1 commentaire

Umme Tania
Umme Tania le 19 Juin 2013
Modifié(e) : Umme Tania le 19 Juin 2013
Thanks.........now it's working

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by