Image Pixel Values

1 次查看(过去 30 天)
Ishtiaq Bercha
Ishtiaq Bercha 2011-5-13
[EDIT: 20110513 15:42 CDT - reformat - WDR]
Hi,
I am new to MATLAB and programing.
I am trying to write a program that performs some image analysis based on pixel values. If I want to determine the mean or max pixel value of image only I want to ensure that the background is removed and actual image is concentrated upon. I am going around this as follows:
x = 256
y = 256
J = dicomread('C:\Documents and Settings\122244\Desktop\DICOMF\IM_0064');
A=[];
for m = 1:x
for n= 1:y
if z = impixelinfo(m,n) >=1
A(m,n) = z
else continue
end
end
end
I will appreciate your tips. Also if you know of medical imaging related MATLAB books, then that would be of value.
Thanks,
---Ish
  2 个评论
Sean de Wolski
Sean de Wolski 2011-5-13
Your FOR-loop is not at all dependent on the image... What is z?
Walter Roberson
Walter Roberson 2011-5-13
Sean, Ishtiaq is expecting z to be assigned the value of impixelinfo(m,n), and then expecting that value to be compared to 1.
There are other languages where that would be a valid statement, but MATLAB isn't one of them.

请先登录,再进行评论。

回答(4 个)

Sean de Wolski
Sean de Wolski 2011-5-13
If J is your image and you want the mean of all values greater than 10:
the_mean = mean(J(J>10));
You'll get a much more useful answer if you post your image with a specific question.
Welcome to MATLAB and Answers!

Matt Fig
Matt Fig 2011-5-13
In addition to what others have said, this line:
if z = impixelinfo(m,n) >=1 % Are you sure about the 1?
is an incorrect use of IF statements. I think you mean:
z = impixelinfo(m,n);
if z>=1
In general, it looks like you want this (assuming J is an image):
J = dicomread('C:\Documents and Settings\122244\Desktop\DICOMF\IM_0064');
A = zeros(size(J),class(J));
A(J>=1) = J(J>=1); % Are you sure about the 1?
But note, that if your goal is only to obtain the mean, and you don't really need A for anything else, the Sean de has the preferred solution.

Walter Roberson
Walter Roberson 2011-5-13
Your use of impixelinfo is incorrect. The two-argument form of impixelinfo is:
impixelinfo(hparent,himage) creates a Pixel Information tool in hparent that provides information about the pixels in himage. himage is a handle to an image or an array of image handles. hparent is a handle to the figure or uipanel object that contains the pixel information tool.
impixelinfo will not return the pixel value at a given offset: you need to index your image for that.
It is also not valid syntax to have an assignment as part of an "if" statement.

Nuwan Liyanage
Nuwan Liyanage 2013-4-1
Hi everyone, I am new to MATLAB too and I will appreciate if anyone could give me an answer for my issue, which is somewhat similar to the original question in someways.
I want to take the pixel values of a ROI which can be defined by a user, to a matrix, and then I can take the average intensity value of that particular potion. this is also regarding mri image analysis. Using impixelinfo command, it gives all the values of the pixels in an image but I want to know a way to get that values into a matrix.
Thanks in advance.
Nuwan
  1 个评论
Image Analyst
Image Analyst 2013-4-1
Please start your own thread and ask how mean2() can be used to calculate the mean of a 2D chunk of your image, and how imcrop() can be used to extract a chunk.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by