prepareimgs.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. DirectoryPathTA ='./datasets/train/med-image/A';
  2. DirectoryPathTB ='./datasets/train/med-image/A';
  3. DirectoryPathTC ='./datasets/train/med-image/A';
  4. DirectoryPathTAhighlight ='./datasets/train/med-image/B';
  5. DirectoryPathTBhighlight ='./datasets/train/med-image/B';
  6. DirectoryPathTChighlight ='./datasets/train/med-image/B';
  7. files = dir('./brainTumorDataPublic_1-766/*.mat');
  8. i = 1;
  9. for file = files'
  10. imgs = load(fullfile('./brainTumorDataPublic_1-766/',file.name));
  11. imgA = imgs.cjdata.image;
  12. imgA = double(imgA);
  13. label = imgs.cjdata.label;
  14. pid = imgs.cjdata.PID;
  15. iptsetpref('ImshowBorder','tight');
  16. figure(1);
  17. imshow(imgA,[0 2825]);
  18. imgB = imgs.cjdata.tumorMask;
  19. figure(2);
  20. imshow(imgB);
  21. imgBdoub = double(imgB)*3000;
  22. img3 = imgA + imgBdoub;
  23. iptsetpref('ImshowBorder','tight');
  24. figure(3);
  25. imshow(img3,[0 6000]);
  26. if label == 1
  27. % Save original image
  28. whereToStore=fullfile(DirectoryPathTA,['A_TA_',num2str(i),'_',pid, '.jpg']);
  29. saveas(figure(1), whereToStore);
  30. whereToStoreLabel=fullfile(DirectoryPathTAhighlight,['B_TB_',num2str(i),'_',pid, '.jpg']);
  31. saveas(figure(3), whereToStoreLabel);
  32. elseif label == 2
  33. whereToStore=fullfile(DirectoryPathTB,['A_TB_',num2str(i),'_',pid, '.jpg']);
  34. saveas(figure(1), whereToStore);
  35. whereToStoreLabel=fullfile(DirectoryPathTBhighlight,['B_TB_',num2str(i),'_',pid, '.jpg']);
  36. saveas(figure(3), whereToStoreLabel);
  37. elseif label == 3
  38. whereToStore=fullfile(DirectoryPathTC,['A_TC_',num2str(i),'_',pid, '.jpg']);
  39. saveas(figure(1), whereToStore);
  40. whereToStoreLabel=fullfile(DirectoryPathTChighlight,['B_TC_',num2str(i),'_',pid, '.jpg']);
  41. saveas(figure(3), whereToStoreLabel);
  42. end
  43. i = i + 1;
  44. end