# Given x and y coordinates of any point in an image, how to know if it is black or white

4 Ansichten (letzte 30 Tage)
Hasan am 20 Mär. 2014
Bearbeitet: Nitin am 21 Mär. 2014
Given x and y coordinates of any point in an image, how to know if it is black or white?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Nitin am 21 Mär. 2014
Bearbeitet: Nitin am 21 Mär. 2014
By the intensity value you get at that point.
For example, if your image is double:
% Edited the mistake as suggested by ImageAnalyst
val = I(y,x);
if val is zero, then it is black.
if val is one, then it is white.
Have a look at a binary image and it will make sense.
bin_img=im2bw(I);
imshow(bin_img),colorbar
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Image Analyst am 21 Mär. 2014
If it's logical or single or double,
if theImage(y, x) == 0
% It's black.
else
% It's white.
end
Or, it if's uint8 instead of logical or double or single, if it's 0 it's black, if it's 255 it's white, and if it's in between it's a shade of gray.
Be careful of the common mistake Nitin made where he said I(x, y). The row (y) is the first index and the column (x) is the second coordinate, so if you want the value at some x,y coordinate, it would be I(y, x).
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by