MATLAB Answers

0

How to read and store pixel intensity and coordinates values of a grayscale-converted image?

Asked by Furkan Kodakoglu on 1 Jul 2019
Latest activity Answered by Divya Gaddipati on 16 Jul 2019
I have a colormap image and I convert it to gray scale using:
A=imread('Image1.jpg')
B=rgb2gray(A)
Now I want to be able to know the pixel intensities of each pixel as a function of their coordinates, or basically just stored with their coordinates such that later I can scan pixel intensities through a desired coordinate range.
I know impixel(B, xi, yi) will give me the pixel intensity that I want at (xi, yi), but where are all these single pixel intensity values are stored? And also impixel() command gives me 3 pixel intensity values, which are all the same, even though the image is grayscale, is there a way to get the single pixel intensity value of the grayscale image?
Thanks,

  0 Comments

Sign in to comment.

1 Answer

Answer by Divya Gaddipati on 16 Jul 2019

Hi,
As I understand, you want to get the pixel intensity value of the grayscale image (B) at a particular location (xi, yi).
You can directly use the matrix row-column indexing method to get the pixel intensity value at a particular location. For example, modifying your code as follows:
A = imread('Image1.jpg')
B = rgb2gray(A)
intensity_value = B(xi, yi);
% xi, yi is the location at which you want to get the intenisty value
The “impixel” function, which you used returns the intensity value as an RGB triplet. Hence, for a grayscale image, R, G and B values obtained will be equal. For more information on how to use “impixel”, you can refer to the following documentation:

  0 Comments

Sign in to comment.