Practicalassignment BI
Practicalassignment BI
Pt.1
Read and display the raw image "rx597x432.raw".
Id=fopen('rx597x432.raw','r');
I=fread(Id, [432 597],'*uint8');
image(I), colormap(gray(256)), axis image
I=I';
slice = imread('slice.bmp');
whos slice
figure, image(slice)
colormap(gray(256))
axis image
1
Read the image "rxcerv.pcx" and display it using first the command image, and
I2=imread('rxcerv.pcx');
image(I2),colormap(gray(256)), axis image
figure,imagesc(I2),colormap(gray(256)),axis image
2
There's no difference because of the "imagesc", it's the same color palette used in both images (uint8).
Repeat the point 5, this time using the image “abdominal.png”. What function suits
I3=imread('abdominal.png');
image(I3),colormap(gray(256)), axis image
figure,imagesc(I3),colormap(gray(256)),axis image
3
The difference between images, is the white contrast, it works better for the "imagesc" function.
Open and visualize the RGB image “tumorRGB.jpg”, What´s its size? Display it
I4=imread('tumorRGB.jpg');
image(I4)
imshow(I4)
4
figure,image(I4)
Read the image “polypRGB.jpg” and display each of its components in a different
window.
I5=imread('polypRGB.jpg','jpg');
polypR=I5(:,:,1);
polypG=I5(:,:,2);
polypB=I5(:,:,3);
temp=0:(1/255):1;
zero=zeros(256,1);
figure(9)
imagesc(I5); title('RGB');
5
figure(10)
imagesc(polypR);colormap([temp' zero zero]);
title('Red')
figure(11)
imagesc(polypG);colormap([zero temp' zero]);
title('Green')
6
figure(12)
imagesc(polypB);colormap([zero zero temp']);
title('Blue');
Read the RGB image “dancersRGB.jpg”, transform it into a grayscale image and
visualize the result. To Transform an RGB image into a grayscale one you must
multiply each of the RGB component by a coefficient and then add all of them, this
7
is:
I6=imread('dancersRGB.jpeg');
imshow(I6)
I6rgb=rgb2gray(I6);
max(I6rgb(:));
min(I6rgb(:));
subplot(1,2,1),imshow(I6)
subplot(1,2,2),imshow(I6rgb)
8
Visualize the transformed image using the different predefined color maps in
matlab.
figure,imagesc(I6rgb),axis image
colormap cool
9
figure,imagesc(I6rgb),axis image
colormap copper
figure,imagesc(I6rgb),axis image
colormap parula
figure,imagesc(I6rgb),axis image
colormap pink
10
Read the dicom image “vrie.dcm” using the command dicomread.
I7=dicomread('vrie.dcm');
size(I7)
ans = 1×4
64 64 1 16
I7=squeeze(I7);
imagesc(I7(:,:,1)),colormap('hot')
11
for i=1:16
subplot(4,4,i), imagesc(I7(:,:,i)),colormap('hot')
end
Dicom files contain “metadata” related to the imaging study performed. To retrieve
this information matlab has the function dicominfo. Display the metadata of the
infod=dicominfo('vrie.dcm')
Warning: File and dictionary VR values do not match for attribute "CodeMeaning" (0008,0104).
Expected: LO. Found: SH. Consider setting the 'UseDictionaryVR' parameter to true.
infod = struct with fields:
Filename: '/Users/diegotapia/Documents/MATLAB/vrie.dcm'
FileModDate: '08-Jun-2005 14:52:40'
FileSize: 136074
Format: 'DICOM'
FormatVersion: 3
Width: 64
Height: 64
BitDepth: 16
ColorType: 'grayscale'
FileMetaInformationGroupLength: 200
FileMetaInformationVersion: [2×1 uint8]
MediaStorageSOPClassUID: '1.2.840.10008.5.1.4.1.1.20'
MediaStorageSOPInstanceUID: '1.2.840.113619.2.84.21524.416529.63.75.1043768211.4'
TransferSyntaxUID: '1.2.840.10008.1.2.1'
ImplementationClassUID: '1.2.840.113619.6.112'
ImplementationVersionName: 'eNTEGRA 2.5202'
SourceApplicationEntityTitle: 'PROCE'
IdentifyingGroupLength: 516
ImageType: 'DERIVED\PRIMARY\GATED\EMISSION'
InstanceCreationDate: '20050608'
InstanceCreationTime: '135240.0000'
12
InstanceCreatorUID: '1.2.840.113619.6.112'
SOPClassUID: '1.2.840.10008.5.1.4.1.1.20'
SOPInstanceUID: '1.2.840.113619.2.84.21524.416529.63.75.1043768211.4'
StudyDate: '20030128'
SeriesDate: '20030128'
AcquisitionDate: '20030128'
ContentDate: '20030128'
StudyTime: '093556.00'
SeriesTime: '093829.00'
AcquisitionTime: '093829.00'
ContentTime: '093829.00'
AccessionNumber: ''
Modality: 'NM'
Manufacturer: 'GE MEDICAL SYSTEMS'
InstitutionName: 'Instituto Nacional de Cardiologia'
ReferringPhysicianName: [1×1 struct]
StationName: 'sala1'
StudyDescription: 'Gated Blood Pool'
SeriesDescription: '45 LAO'
NameOfPhysiciansReadingStudy: [1×1 struct]
OperatorsName: [1×1 struct]
ManufacturerModelName: 'MILLENNIUM MPT'
Private_0009_GroupLength: 488
Private_0009_10xx_Creator: 'GEMS_GENIE_1'
Private_0009_1001: 'GEMS_GENIE'
Private_0009_1010: 'MULTIGATED'
Private_0009_1011: 4105
Private_0009_1012: 1
Private_0009_101e: '1.2.840.113619.2.84.21524.416529.63.75.1043768211.4'
Private_0009_1020: '45 LAO'
Private_0009_1021: 1
Private_0009_1022: ''
Private_0009_1023: 2
Private_0009_1024: 60000
Private_0009_1025: 1000
Private_0009_1026: 1
Private_0009_1027: 1
Private_0009_1028: 1
Private_0009_1029: 16
Private_0009_102a: 0
Private_0009_102b: ''
Private_0009_102c: ''
Private_0009_102d: 0
Private_0009_102e: 0
Private_0009_102f: 0
Private_0009_1037: 58
Private_0009_103a: 100
Private_0009_1040: [1×1 struct]
Private_0009_1041: 1
Private_0009_1042: '20030128'
Private_0009_1043: '093647.00'
Private_0009_1045: '1.2.840.113619.2.84.21524.416529.63.75.1043768211.4'
PatientGroupLength: 112
PatientName: [1×1 struct]
PatientID: '00'
PatientBirthDate: ''
PatientSex: 'M'
OtherPatientIDs: ''
OtherPatientNames: [1×1 struct]
PatientSize: 0
PatientWeight: 0
EthnicGroup: ''
Occupation: ''
Private_0011_GroupLength: 654
13
Private_0011_10xx_Creator: 'GEMS_GENIE_1'
Private_0011_100a: 3
Private_0011_100b: 300280
Private_0011_100c: 238
Private_0011_100d: 'Tc99m'
Private_0011_1010: ''
Private_0011_1011: 0
Private_0011_1012: '45 LAO'
Private_0011_1013: 11
Private_0011_1014: ''
Private_0011_1015: 1
Private_0011_1016: 1
Private_0011_1017: 1
Private_0011_1018: 0
Private_0011_1019: 181.1830
Private_0011_101a: 1
Private_0011_101f: 0
Private_0011_1026: 0
Private_0011_1027: [2×1 int32]
Private_0011_1028: [2×1 int32]
Private_0011_102c: 0
Private_0011_102d: 0
Private_0011_102e: 0
Private_0011_102f: 32767
Private_0011_1030: '45 LAO'
Private_0011_1031: '**'
Private_0011_1032: '**'
Private_0011_1033: 'ECOR'
Private_0011_1034: 'Tc99m'
Private_0011_1035: 'PMT'
Private_0011_1036: '**'
Private_0011_1037: '**'
Private_0011_1038: 108
Private_0011_1039: 0
Private_0011_103a: 5
Private_0011_103b: 1
Private_0011_103c: 0
Private_0011_103f: 9
Private_0011_1040: 'current'
Private_0011_1041: 0
Private_0011_1042: 0
Private_0011_1043: 0
Private_0011_1044: 2048
Private_0011_1045: 4096
Private_0011_1046: 2
Private_0011_1050: '45 LAO'
Private_0011_1055: 1
Private_0011_1056: 1
Private_0011_1057: [2×1 double]
Private_0013_GroupLength: 84
Private_0013_10xx_Creator: 'GEMS_GENIE_1'
Private_0013_1010: [2×1 double]
Private_0013_1011: 4
Private_0013_1012: 0
Private_0013_1015: 0
Private_0015_GroupLength: 32
Private_0015_10xx_Creator: 'GEMS_GENIE_1'
Private_0015_1017: 0
AcquisitionGroupLength: 196
BodyPartExamined: 'HEART'
CountsAccumulated: 4051048
AcquisitionTerminationCondition: 'TIME'
DeviceSerialNumber: '192.168.2.1'
SoftwareVersions: '2.7: FW 3-1_01'
14
ProtocolName: 'Gated Blood Pool'
TriggerSourceOrType: 'EKG'
BeatRejectionFlag: 'Y'
SkipBeats: 1
HeartRate: 57
TableHeight: 0
TableTraverse: 0
CountRate: 16709
PatientPosition: 'FFS'
Private_0019_GroupLength: 32
Private_0019_10xx_Creator: 'GEMS_GENIE_1'
Private_0019_105f: [1×1 struct]
RelationshipGroupLength: 242
StudyInstanceUID: '1.2.840.113619.2.84.21524.416529.4.70.1043768156.1'
SeriesInstanceUID: '1.2.840.113619.2.84.21524.416529.63.69.1043768210.3'
StudyID: 'MULTIGATED'
SeriesNumber: 3034
InstanceNumber: 11637
FrameOfReferenceUID: '1.2.840.113619.2.84.21524.416529.63.69.1043768210.3.3034'
Laterality: ''
PositionReferenceIndicator: ''
ImagePresentationGroupLength: 226
SamplesPerPixel: 1
PhotometricInterpretation: 'MONOCHROME2'
NumberOfFrames: 16
FrameIncrementPointer: [84 16 84 32 84 96 84 112]
Rows: 64
Columns: 64
PixelSpacing: [2×1 double]
BitsAllocated: 16
BitsStored: 16
HighBit: 15
PixelRepresentation: 1
SmallestImagePixelValue: 0
LargestImagePixelValue: 278
SmallestPixelValueInSeries: 0
LargestPixelValueInSeries: 278
WindowCenter: 139
WindowWidth: 278
Private_0033_GroupLength: 80
Private_0033_10xx_Creator: 'GEMS_GENIE_1'
Private_0033_1007: '1.2.840.113619.2.84.21524.416529.63.75.1043768211.4'
Unknown_0040_0000: 12
RequestAttributesSequence: [1×1 struct]
NuclearAcquisitionGroupLength: 1264
EnergyWindowVector: [16×1 uint16]
NumberOfEnergyWindows: 1
EnergyWindowInformationSequence: [1×1 struct]
RadiopharmaceuticalInformationSequence: [1×1 struct]
DetectorVector: [16×1 uint16]
NumberOfDetectors: 1
DetectorInformationSequence: [1×1 struct]
RRIntervalVector: [16×1 uint16]
NumberOfRRIntervals: 1
GatedInformationSequence: [1×1 struct]
TimeSlotVector: [16×1 uint16]
NumberOfTimeSlots: 16
ImageID: '45 LAO'
PatientOrientationCodeSequence: [1×1 struct]
PatientGantryRelationshipCodeSequence: [1×1 struct]
Private_0055_GroupLength: 528
Private_0055_10xx_Creator: 'GEMS_GENIE_1'
Private_0055_1012: [1×1 struct]
Private_0055_1022: [1×1 struct]
15
Private_0055_1062: [1×1 struct]
Private_0055_1065: [1×1 struct]
PixelDataGroupLength: 131084
I8 = imfinfo('Rx_knee_foot.tif','tiff');
size(I8)
ans = 1×2
4 1
I8(3)
Open all of the images in the file “Rx_knee_foot.tif” and display them in the same
I9=imread('Rx_knee_foot.tif',1);
I10=imread('Rx_knee_foot.tif',2);
I11=imread('Rx_knee_foot.tif',3);
I12=imread('Rx_knee_foot.tif',4);
figure,
16
subplot(2,2,1), imshow(I9);
subplot(2,2,2), imshow(I10);
subplot(2,2,3), imshow(I11);
subplot(2,2,4), imshow(I12);
Pt. 2
Write a matlab function whose input argument is an image in a matlab supported
format and its output argument is the same image in a raw format.
inputI: MATLAB supported image format, outputFN; Name for the output raw file, get image size, and convert
to .Raw, finally display to confirm the process was OK.
Id=fopen('rosa2.raw','r');
I13=fread(Id,[432 597],'*uint8');
figure,
image(I13),colormap(gray(256)), axis image
I13=I13';
Create a function that makes the same task as the command imresize, to reduce the
17
I14=imread('rosa.jpg');
figure, imshow(I14)
ri = ci('rosa.jpg', 0.5)
imshow(ri)
Figure out the right way to visualize the indexed image “cta_scan_index.bmp”
I15 = imread('cta_scan_index.bmp');
[b,bmap]=imread('cta_scan_index.bmp');
figure,
subplot(1, 2, 1);
imshow(I15);
subplot(1, 2, 2);
imshow(b,bmap)
18