Filter löschen
Filter löschen

How I can change the more than one pixel values in gray scale image ?

1 Ansicht (letzte 30 Tage)
% I have gray image X (480x640 double), having values between 0 and 0 to 1, I want to change the values of all pixel to 1 that are closer to 1 and change values of all pixel to 0 that are near to 0.

Akzeptierte Antwort

Image Analyst
Image Analyst am 26 Okt. 2012
Bearbeitet: Image Analyst am 26 Okt. 2012
Well, you shouldn't have accepted that answer so quickly if it didn't do what you asked. Here's how to "change the values of certain pixel to 1 that are closer to 1 and want to change values to 0 that are near to 0:
yourImage = yourImage >= 0.5;
  3 Kommentare
Image Analyst
Image Analyst am 26 Okt. 2012
I'm not sure what you mean.
Here's an example:
yourImage = rand(3)
yourImage = yourImage >= 0.5
and in the command window.
yourImage =
0.964888535199277 0.957166948242946 0.141886338627215
0.157613081677548 0.485375648722841 0.421761282626275
0.970592781760616 0.8002804688888 0.915735525189067
yourImage =
1 1 0
0 0 0
1 1 1
as you can see, it changed values that are closer to 0 into 0, and values that are closer to 1 into 1, just exactly what you asked. By the way, it also works for any range of values, not just values in between 0 and 1. So, given the yourImage above, what values would you want them to be changed into?
TURI
TURI am 29 Okt. 2012
Let say I have image I= [0 0 0 0.0500 0.0512 0.0473 0.0774 0.0735 0.0735 0.0774 0.0774 0.0735 0.0774 0.0735 0.0747 ] Now i wanna change all similar pixel like 0.0735 to my desire color let say red/white. please write the code with comment so i can understand. Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Wayne King
Wayne King am 26 Okt. 2012
Bearbeitet: Wayne King am 26 Okt. 2012
The function round(), rounds to the nearest integer.
X = rand(480,640);
Xnew = round(X);

Community Treasure Hunt

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

Start Hunting!

Translated by