dice_score.m 540 B

12345678910111213141516171819202122232425262728
  1. imgs = load('./brainTumorDataPublic_1-766/500.mat');
  2. binaryMask = imgs.cjdata.tumorMask;
  3. iptsetpref('ImshowBorder','tight');
  4. figure(2);
  5. imshow(img2,[ ]);
  6. I = imread('A_2_A2B.jpg');
  7. %Convert the image into a binary image.
  8. figure(3);
  9. imshow(I,[ ]);
  10. Igray = rgb2gray(I);
  11. BW = imbinarize(Igray);
  12. figure(4);
  13. imshow(BW,[ ]);
  14. %Display the original image next to the binary version.
  15. figure(3);
  16. imshowpair(I,BW,'montage');
  17. andImage = binaryMask & BW;
  18. orImage = binaryMask | BW;
  19. diceCoeff = sum(andImage) / sum(orImage);
  20. disp(diceCoeff);