Ciri geometri di antaranya adalah jarak dan sudut.
Jarak antara dua buah titik (dengan satuan piksel) dapat ditentukan menggunakan persamaan euclidean, minkowski, manhattan, dll.
Jarak dengan satuan piksel tersebut dapat dikonversi menjadi satuan panjang seperti milimeter, centimeter, meter, dll dengan cara membaginya dengan resolusi spasial.
Sedangkan sudut antara dua buah garis dapat ditentukan dengan perhitungan trigonometri maupun dengan analisis vektor.
Dalam sistem koordinat citra dua dimensi, jarak antara dua objek dapat diukur menggunakan persamaan euclidean distance.
Berikut ini merupakan contoh aplikasi pemrograman matlab untuk mengukur jarak antara dua objek dalam citra phantom berformat dicom. Langkah-langkahnya adalah sebagai berikut:
1. Membaca citra phantom berformat dicom

3. Menentukan centroid dan labelling objek

4. Mengukur jarak antara dua objek
menggunakan persamaan euclidean distance dalam satuan piksel. Satuan
piksel kemudian dikonversi menjadi satuan mm dengan cara membagi hasil
pengukuran jarak dalam satuan piksel dengan resolusi spasial (pada
contoh ini diketahui resolusi spasial citra adalah sebesar 1,4798 piksel
per mm). Pengukuran jarak antara objek 1 dengan objek 2 ditunjukkan
pada gambar berikut:

5. Pengukuran jarak antara objek 1 dan objek 3

6. Pengukuran jarak antara objek 1 dan objek 4

7. Pengukuran jarak antara objek 2 dan objek 3

8. Pengukuran jarak antara objek 2 dan objek 4

9. Pengukuran jarak antara objek 3 dan objek 4

File source code lengkap beserta citra dicom pada materi di atas dapat diperoleh melalui halaman berikut ini: Source Code
Sedangkan tampilan source codenya adalah:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | clc;clear;close all;I = dicomread('slice1.dcm');figure(1), imshow(I,[]);BW = I>3000;figure(2), imshow(BW,[]);s = regionprops(BW, 'centroid');centroids = cat(1,s.Centroid);% labelling[B,L] = bwboundaries(BW,'noholes');[~,num] = bwlabel(BW,8);figure(3), imshow(I,[])hold onfor k = 1:num boundary = B{k}; text(boundary(1,2)+20,boundary(1,1),strcat(['Object ',num2str(k)]),'Color','y',... 'FontSize',14,'FontWeight','bold'); plot(centroids(:,1), centroids(:,2), 'b*')endhold off% object 1 & 2x1 = centroids(1,1);y1 = centroids(1,2);x2 = centroids(2,1);y2 = centroids(2,2);figure(4), imshow(I,[])hold onplot([x1;x2], [y1;y2], 'r','LineWidth',3)d_px = sum(([x1;y1]-[x2;y2]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x1+x2+20)/2,(y1+y2)/2,strcat(['d = ',num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x1+x2+20)/2,(y1+y2+40)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off% object 1 & 3x1 = centroids(1,1);y1 = centroids(1,2);x3 = centroids(3,1);y3 = centroids(3,2);figure(5), imshow(I,[])hold onplot([x1;x3], [y1;y3], 'g','LineWidth',3)d_px = sum(([x1;y1]-[x3;y3]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x1+x3+20)/2,(y1+y3)/2,strcat(['d = ',num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x1+x3+20)/2,(y1+y3+40)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off% object 1 & 4x1 = centroids(1,1);y1 = centroids(1,2);x4 = centroids(4,1);y4 = centroids(4,2);figure(6), imshow(I,[])hold onplot([x1;x4], [y1;y4], 'b','LineWidth',3)d_px = sum(([x1;y1]-[x4;y4]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x1+x4+20)/2,(y1+y4)/2,strcat('d = ',[num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x1+x4+20)/2,(y1+y4+40)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off% object 2 & 3x2 = centroids(2,1);y2 = centroids(2,2);x3 = centroids(3,1);y3 = centroids(3,2);figure(7), imshow(I,[])hold onplot([x2;x3], [y2;y3], 'c','LineWidth',3)d_px = sum(([x2;y2]-[x3;y3]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x2+x3)/2,(y2+y3-60)/2,strcat(['d = ',num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x2+x3)/2,(y2+y3-20)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off% object 2 & 4x2 = centroids(2,1);y2 = centroids(2,2);x4 = centroids(4,1);y4 = centroids(4,2);figure(8), imshow(I,[])hold onplot([x2;x4], [y2;y4], 'm','LineWidth',3)d_px = sum(([x2;y2]-[x4;y4]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x2+x4+20)/2,(y2+y4)/2,strcat(['d = ',num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x2+x4+20)/2,(y2+y4+40)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off% object 3 & 4x3 = centroids(3,1);y3 = centroids(3,2);x4 = centroids(4,1);y4 = centroids(4,2);figure(9), imshow(I,[])hold onplot([x3;x4], [y3;y4], 'y','LineWidth',3)d_px = sum(([x3;y3]-[x4;y4]).^2).^0.5;res = 1.4798;d_mm = d_px/res;text((x3+x4+20)/2,(y3+y4)/2,strcat(['d = ',num2str(d_px),' px']),'Color','y',... 'FontSize',14,'FontWeight','bold');text((x3+x4+20)/2,(y3+y4+40)/2,strcat(['d = ',num2str(d_mm),' mm']),'Color','y',... 'FontSize',14,'FontWeight','bold');hold off |


