Hi all
Hope you are keeping good and enjoying a lot. i contoured some region of a image using imfreehand. i want to caculate the volume of every pixel inside the contour. but the information i have get in pixels[X and Y coordinate values are in pixel] and Z coordinate is thickness of the image which is in cm. i need to convert the pixel to cm to get the volume of the each pixel. is there any formula or any suggestions???
but for the whole image i have voxel size information as below. voxel size [Y=0.09cm, Y=0.09cm, Z=0.18cm].will this helpful.
any help is appreciated in advance.

댓글 수: 6

mohd akmal masud
mohd akmal masud 2017년 12월 6일
Dear Muhammad, How you find the voxel size? [Y=0.09cm, Y=0.09cm, Z=0.18cm]????
Walter Roberson
Walter Roberson 2017년 12월 6일
Voxel size information can be found from dicom headers if dicom was used. For MRI images the information is there fairly directly.
mohd akmal masud
mohd akmal masud 2017년 12월 6일
Thank You Walter Roberson. I got it..
Oscar Garcia
Oscar Garcia 2021년 7월 31일
Hi I was actually curious so I need to calculate the volume of a flir thermal image and my best bet is to use pixels to cm but I’m not quite sure if it’s possible to convert it from a thermal image please help if possible
Walter Roberson
Walter Roberson 2021년 7월 31일
I do not recall having encountered a flir image that had depth information. I suppose in theory you could infer depth if you had stereo flir images, which is something that could be done and could perhaps be useful... is that what you have, two flir images of the same scene with different angles and known relationships between the views??
Image Analyst
Image Analyst 2021년 7월 31일
편집: Image Analyst 2021년 7월 31일
@Oscar Garcia (expand comments to wee Walter's above mine), what is your definition of volume? You mean the true spatial volume like units of cubic cm? You can't get that from a single 2-D image, not even a range/topographic image unless you make some assumptions as to where the "back" of the object is and what shape it has. Or maybe you mean the integrated gray value in some region of interest -- kind of like the intensity was a surface and you want the volume below the surface. I suggest you start your own question and attach your images and indicate what region in the image you want the "volume" of. In the meantime, see attached spatial calibration demo.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 9월 17일

0 개 추천

Multiply number of pixels by 0.09cm to get length in cm. Number of total pixels times (0.09)^2 to get the area in cm^2. Multiply that by 0.18 to get volume in cm^3

댓글 수: 7

Muhammad
Muhammad 2013년 9월 17일
good. if i have X and Y coodinate of contoured region. then multiply X coordinate pixel value to 0.09cm to get a lenght in cm. Y coordinate with 0.09cm to get the width in cm and multiply lengthxwidthx0.18 to get volume of the pixel??? is this right? suppose X pixelcoordinate value 236= 236x0.09= 21.24cm same for the Y 117= 117x0.09=10.53cm Volume= 21.24x10.53x0.18=40.25cm^3 is this right?
Walter Roberson
Walter Roberson 2013년 9월 17일
Do not multiply coordinates, multiply number of pixels. If you had 236 pixels in X and 117 pixel in Y (236 x 117 area) then yes, 236 * 117 * 0.09 * 0.09 * 0.18 cm^3
listen. a pixel is 2 dimensional (x and y). suppose if i contour some region by imfreehand and i get 200 x and 200 y values on a excel sheet. this mean that there are 200 pixels in that region. am i right? i need volume of each pixel? now i think is better to understand. now give me the suggestion. i am aslo giving my code below.
if true
function ExcelPushbutton_Callback(hObject, eventdata, handles)
[X, Y] = find(handles.maskedImage ~= 0);
data=[Y,X];
Z = repmat(0.18,[length(X),1]);
A=times(X,Y);
volume=times(A,Z);
[FileName,PathName] = uiputfile('*.xls','Save data to spreadsheet');
Data=[X,Y,Z,volume];
xlswrite([PathName '/' FileName],Data); end
Image Analyst
Image Analyst 2013년 9월 17일
No that's not right, for a variety of reasons. First of all, imfreehand does not give continuous pixels - there can be gaps. For example if you draw really fast a square of 200 by 200 pixels, you could get 700 (x,y) coordinates, or 600 or 400 or 100, depending on how fast you drew. But whatever . . . let's say that you know for a fact that there are 200*200 = 40,000 pixels ( not 200) in the area. Then you multiply 40,000 * 0.09^2 to get the area, then multiply by .18 to get the volume. If you have a rectangle and x = 236 and the other corner is as x = 336, then the distance is 100 pixels (if you're using center-to-center, otherwise if you're counting pixels it's 101 pixels). So it's the delta x you want to multiply by the calibration factor: abs(336-236)*0.09. If you do it to one then you have to do it to the other and then that will work too: distance = .09*336 - .09*236.
Muhammad
Muhammad 2013년 9월 17일
편집: Muhammad 2013년 9월 17일
oh i am too much confued. let me explain again. when i contour by imfreehand, then i found a excel sheet. that excel sheet contains 197 rows and 3 columns [X,Y,Z] but Z=0.18cm. each row has different X and Y coordinate. Now, i want to calculate the Volume of every row. can i do this? if yes, then how can i do?
Image Analyst
Image Analyst 2013년 9월 17일
How did you find this workbook?
Can't you just plug the x and y into polyarea() to get the area in pixels, then multiply by 0.09^2 to get the area in cm^2?
Muhammad
Muhammad 2013년 9월 18일
편집: Muhammad 2013년 9월 18일
Dear Dr. i am sending you my 2 pushbuttons program.which will tell how i created that workbook. 1 pushbutton is to contoure and other is to creat Excel sheet. please guide me about this. is this right or wrong way? and how can we calculate the volume of single pixel? as you know single pixel is a voxel because if its its coordinates are (x,y, thickness). if i say i want Volume of each Voxel inside the contoure region then it will better. hoping for early response;
if true
function Contourpushbutton_Callback(hObject, eventdata, handles)
% imfreehand
h=imfreehand(gca,'closed',0);
% waitfor(h);
pos = getPosition(h);
% sz = size(handles.listbox1);
handles.output = hObject;
index = get(handles.listbox1,'value');
sz = size(handles.I{index});
handles.maskedImage = poly2mask(pos(:,1), pos(:,2), sz(1), sz(2));
guidata(hObject, handles); %use this line to save the handles structure during callbacks
end
if true
% --- Executes on button press in ExcelPushbutton.
function ExcelPushbutton_Callback(hObject, eventdata, handles)
[X, Y] = find(handles.maskedImage ~= 0);
data=[Y,X];
Z = repmat(0.18,[length(X),1]);
A=times(X,Y);
volume=times(A,Z);
[FileName,PathName] = uiputfile('*.xls','Save data to spreadsheet');
Data=[X,Y,Z,volume];
xlswrite([PathName '/' FileName],Data);
end

댓글을 달려면 로그인하십시오.

질문:

2013년 9월 17일

편집:

2021년 7월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by