Could you please help me with the following question?
My code reads a DICOM image. The image is 512 * 512 uint 16.
The code draws an ROI on the image. After creating a mask, the code gets X and Y coordinates as well as the intensity of each pixel within the mask.
The result is a matrix of n by m, which its value corresponds to the image intensity. I want to know how I can pass this matrix to the graycomatrix function?

 Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Sep. 2021

0 Stimmen

See attached example.

3 Kommentare

Thank you Image Analyst. But, I could not find the answer to my question. I want to know how I should pass the matrix to the graycomatrix function.
I use the following code to create the matrix:
for i = 1:size(n)
iy = XROI(n(i, 1));
ix = YROI(n(i, 1));
intens = PixelValues(n(i, 1));
imgmap(ix, iy) = intens;
end
Where n represents the number of the pixels within the mask. XROI is the X-coordinates of all pixels within the mask. YROI is the Y-coordinates of all pixels within the mask. intens is intensity of the corresponding pixel.
The imgmap is the matrix
Then, should I pass the matrix as an image to the graycomatrix function?
If yes, which of the following code is correct:
NewImage = uint8(imgmap);
or given the original image is uint 16, I shoudl use:
NewImage = uint16(imgmap);
glcm = graycomatrix(NewImage, 'Offset', offsets);
or I can directly plugin the matrix:
glcm = graycomatrix(imgmap, 'Offset', offsets);
Walter Roberson
Walter Roberson am 30 Sep. 2021
Bearbeitet: Walter Roberson am 30 Sep. 2021
imgmap = zeros(max(YROI(n(:,1))), max(XROI(n(:,1))), 'like', PixelValues);
for i = 1:size(n, 1)
iy = XROI(n(i, 1));
ix = YROI(n(i, 1));
intens = PixelValues(n(i, 1));
imgmap(iy, ix) = intens;
end
glcm = graycomatrix(imgmap, 'Offset', offsets);
Note: you had x and y reversed. X is horizontal distance, which is column number. y is vertical distance, which is row number.
Nathan Armani
Nathan Armani am 30 Sep. 2021
Thank you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by