MATLAB Answers

how to convert Pixel to cm

42 views (last 30 days)
Muhammad on 17 Sep 2013
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.


mohd akmal masud
mohd akmal masud on 6 Dec 2017
Dear Muhammad, How you find the voxel size? [Y=0.09cm, Y=0.09cm, Z=0.18cm]????
Walter Roberson
Walter Roberson on 6 Dec 2017
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 on 6 Dec 2017
Thank You Walter Roberson. I got it..

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 17 Sep 2013
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


Show 4 older comments
Muhammad on 17 Sep 2013
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 on 17 Sep 2013
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 on 18 Sep 2013
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
% 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
if true
% --- Executes on button press in ExcelPushbutton.
function ExcelPushbutton_Callback(hObject, eventdata, handles)
[X, Y] = find(handles.maskedImage ~= 0);
Z = repmat(0.18,[length(X),1]);
[FileName,PathName] = uiputfile('*.xls','Save data to spreadsheet');
xlswrite([PathName '/' FileName],Data);

Sign in to comment.

Sign in to answer this question.