Image Pixel Values
2 ビュー (過去 30 日間)
古いコメントを表示
[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 件のコメント
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
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!
0 件のコメント
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.
0 件のコメント
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.
0 件のコメント
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
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 Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!