Hi,
maybe this snippet is helpful for You
// get Length (absolute value of the vector) and multiply by
// horizontal and vertical imager pixel spacing (if not isset imager Pixel Spacing try pixelSpacing)
// of DICOM-Header
/*
* Point 1 (C1,R1)
Point 2 (C2,R2)
Spacing (Cs,Rs)
distance (mm) = sqrt( ((C2-C1)*Cs)**2 + ((R2-R1)*Rs)**2 )
*/
double horizontalSpacing = ...;
double verticalSpacing = ...;
double pixelLength = Math.sqrt(Math.pow(((lineX-distAx)*horizontalSpacing),2)+Math.pow(((lineY-distAy)*verticalSpacing),2));
// divide by the zoomfactor
pixelLength = pixelLength/getMagnification();
// round
int pixelLengthInt = (int) Math.round(pixelLength);
if(horizontalSpacing!=-1 && verticalSpacing!=-1)
this.lineLength = pixelLengthInt+" mm";
njd wrote
I am currently trying to use ImageJ to make absolute measurements in millimetres. My results are calculated as a number of pixels. Could I use a different file type (DICOM/.tiff?) to allow this to be converted to mm?
I am aware that I can use the set scale function, but am wondering whether there is some way for imagej to recognise scale from the file itself rather than the user having to do conversion measurements, which might introduce some error.
I'd be grateful if you could assist with this query.
Thanks,
Niall