Image Pixel Values

조회 수: 3 (최근 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 Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by