How can I calculate the area of white pixels of binary image in mm2

I need to find the size of tumor,that is white pixels of a binary image.I used the following equation to calculate the number of white pixel in my image.
Number of white pixels= int2str(nnz(binarized_img));
Now i have the count of white pixels,how can i find out the size of white pixels using this count? I have already referred this link, but i didn't understand it properly.In my case,i have to find the size of tumor,how can I do it with the number of white pixels that I have now.

 Réponse acceptée

You need to find out how big one pixel is, in appropriate units, and then multiply by the number of pixels you have identified.
If you are working with a JPEG image, chances are that you will not have accurate information stored in the original file necessary to calculate the real-world size of the pixels. If you are using something designed specifically as a scientific instrument, then the information might be there in a JPEG image. Also, some models of high-end cameras store auto-focus distance and aperture information that can be used to estimate real-world sizes -- for example not even all Canon DSLRs will have that information.
Note: the "Resolution" EXIF information that is stored with JPEG images is more likely to be garbage than not.
If you are working with an image that was originally recorded directly as a TIFF or PNG file, the probability goes up that meaningful information is stored with the file.
If you are working with an image that was originally recorded as a DICOM image, then chances are quite good that the DICOM headers have the detailed information you need to calculate the pixel area.

12 commentaires

Actually I'm using an JPEG image which was converted from a DICOM image,how can I know the size of one pixel from this image?
Use the DICOM image instead. The JPEG headers in that case definitely will not contain the information you need.
Also, unless the people who did the conversion were careful to use JPEG lossless mode, all of the edges were blurred by the JPEG compression process, making it much more difficult to accurately detect the boundaries. Using the DICOM image directly eliminates that problem. (Unless the people who created the DICOM image messed up and used lossy JPEG as part of the DICOM Transfer Syntax!)
Okey,I'll do it.Can you please tell me how can I calculate the size after these steps
Use dicominfo() on the .dcm and save the output to a structure.
Check to see if it has a PixelSpacing field: if it does then that is the distance between the center of pixels, which is what you need to know. The first value of the pair will be the row spacing; the second will be the column spacing.
If not check for ImagerPixelSpacing and then NominalScannedPixelSpacing .
If none of those exist then it might be possible to deduce the spacing from one of the items that are recorded, but I would probably need to see the output of dicominfo() to figure it out.
For more information see starting from page 101 of http://dicom.nema.org/Dicom/2011/11_03pu.pdf
Thanks a lot.Ill try those.
The is what i got when i used dicominfo
PixelSpacing: [2x1 double]
FileModDate: '18-Jan-2016 21:45:26'
FileSize: 527820
Format: 'DICOM'
FormatVersion: 3
Width: 512
Height: 512
BitDepth: 12
ColorType: 'grayscale'
FileMetaInformationGroupLength: 208
FileMetaInformationVersion: [2x1 uint8]
MediaStorageSOPClassUID: '1.2.840.10008.5.1.4.1.1.4'
MediaStorageSOPInstanceUID: '1.3.46.670589.11.0.0.11.4.2.0.8743.5.3800.2006120117111325022'
TransferSyntaxUID: '1.2.840.10008.1.2.1'
ImplementationClassUID: '1.3.6.1.4.1.19291.2.1'
ImplementationVersionName: 'OSIRIX001'
SourceApplicationEntityTitle: 'OSIRIX'
SpecificCharacterSet: 'ISO_IR 100'
ImageType: 'ORIGINAL\PRIMARY\M_SE\M\SE'
InstanceCreationDate: '20061201'
InstanceCreationTime: '171242.000000'
InstanceCreatorUID: '1.3.46.670589.11.8743.5'
SOPClassUID: '1.2.840.10008.5.1.4.1.1.4'
SOPInstanceUID: '1.3.46.670589.11.0.0.11.4.2.0.8743.5.3800.2006120117111325022'
StudyDate: '20061201'
SeriesDate: '20061201'
AcquisitionDate: '20061201'
ContentDate: '20061201'
StudyTime: '141645.000000'
SeriesTime: '143958.890000'
AcquisitionTime: '143958.890000'
ContentTime: '143958.890000'
AccessionNumber: '0'
Modality: 'MR'
Manufacturer: 'Philips Medical Systems'
InstitutionName: '7GEFF0GbzqCNo43Yd0,Ibu,zQSSX'
ReferringPhysicianName: [1x1 struct]
StationName: 'intera'
StudyDescription: 'IRM cérébrale, neuro-crâne'
ProcedureCodeSequence: [1x1 struct]
SeriesDescription: 'SOUS'
InstitutionalDepartmentName: 'Radiologie'
ManufacturerModelName: 'Achieva'
ReferencedStudySequence: [1x1 struct]
ReferencedPerformedProcedureStepSequence: [1x1 struct]
ReferencedImageSequence: [1x1 struct]
PatientName: [1x1 struct]
PatientID: '5Yp0E'
PatientBirthDate: '19490301'
PatientSex: '0000'
PatientWeight: 0
PregnancyStatus: 4
ScanningSequence: 'SE'
SequenceVariant: 'SS'
ScanOptions: 'FC'
SliceThickness: 5
RepetitionTime: 449.9990
EchoTime: 10
NumberOfAverages: 3
ImagingFrequency: 63.9074
ImagedNucleus: '1H'
EchoNumber: 1
MagneticFieldStrength: 1.5000
SpacingBetweenSlices: 6
NumberOfPhaseEncodingSteps: 240
EchoTrainLength: 0
PercentSampling: 75
PercentPhaseFieldOfView: 75
DeviceSerialNumber: '08743'
SoftwareVersion: [1x208 char]
ProtocolName: 'SOUS'
LowRRValue: 0
HighRRValue: 0
IntervalsAcquired: 0
IntervalsRejected: 0
HeartRate: 0
ReconstructionDiameter: 240
ReceiveCoilName: 'SENSE-Head'
TransmitCoilName: 'B'
AcquisitionMatrix: [4x1 uint16]
InPlanePhaseEncodingDirection: 'ROW'
FlipAngle: 90
PatientPosition: 'HFS'
StudyInstanceUID: '2.16.840.1.113669.632.20.1211.10000357775'
SeriesInstanceUID: '1.3.46.670589.11.0.0.11.4.2.0.8743.5.3800.2006120117110979000'
StudyID: '218211405'
SeriesNumber: 702
SeriesNumber: 702
AcquisitionNumber: 7
InstanceNumber: 1
ImagePositionPatient: [3x1 double]
ImageOrientationPatient: [6x1 double]
FrameOfReferenceUID: '1.3.46.670589.11.0.0.11.4.2.0.8743.5.6032.2006120114240131000'
TemporalPositionIdentifier: 1
NumberOfTemporalPositions: 1
SliceLocation: 126.0000
SamplesPerPixel: 1
PhotometricInterpretation: 'MONOCHROME2'
Rows: 512
Columns: 512
PixelSpacing: [2x1 double]
PixelAspectRatio: [2x1 double]
BitsAllocated: 16
BitsStored: 12
HighBit: 11
PixelRepresentation: 0
WindowCenter: 2.8564e+003
WindowWidth: 2475
LossyImageCompression: '00'
RequestingService: 'IRMCEREB'
RequestedProcedureDescription: 'IRM cérébrale, neuro-crâne'
PerformedStationAETitle: 'INTERA'
PerformedProcedureStepStartDate: '20061201'
PerformedProcedureStepStartTime: '141645.000000'
PerformedProcedureStepEndDate: '20061201'
PerformedProcedureStepEndTime: '141645.000000'
PerformedProcedureStepID: '218211405'
PerformedProcedureStepDescription: 'IRM cérébrale, neuro-crâne'
PerformedProtocolCodeSequence: [1x1 struct]
RequestAttributesSequence: [1x1 struct]
FilmConsumptionSequence: [1x1 struct]
RequestedProcedureID: 'A10029316690'
PresentationLUTShape: 'IDENTITY'
It shows up in that form when you display the entire structure. If you access just the one field of the structure then it should be fine.
I notice that there is a 90 degree rotation in the header, so be careful about which direction is X and which is Y, keeping in mind that for MATLAB images, Y is the first index (row number)
Suba Suba
Suba Suba le 13 Sep 2016
Modifié(e) : Suba Suba le 13 Sep 2016
@Walter Roberson I didn't get your comment, I'm sorry to ask the question again,can you please elaborate the steps that I need to do to find the size of pixel.This is the first time I'm dealing with the matlab language.Please help me to do this.
dinfo = dicominfo('TheFileName.dcm');
spacing = dinfo.PixelSpacing;
per_pixel_area = spacing(1) * spacing(2);
num_white_pixels = nnz(binarized_img);
total_white_area = num_white_pixels * per_pixel_area;
Thanks a lot.Ill try these.
What's final areas unit??
Revati shiudkar:
DICOM PixelSpacing related values are in mm (millimetres) so area would be in mm^2

Connectez-vous pour commenter.

Plus de réponses (1)

I want a tool like a ruler to measure distances in dicom images. In cm. using matlab

Catégories

En savoir plus sur DICOM Format dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by