Facebook
From aa, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 62
  1. %Read an image
  2. img= imread('21_training.tif');
  3. red= img(:,:,1);
  4. green= img(:,:,2);
  5. blue= img(:,:,3);
  6.  
  7. %Display RGB components in separate subplots
  8. subplot(1,3,1)
  9. imshow(red);
  10. subplot(1,3,2)
  11. imshow(green);
  12. subplot(1,3,3)
  13. imshow(blue);
  14.  
  15. %Choose the RGB component  
  16. color = green; %Green
  17.  
  18. %Compute gradient magnitude image (imgradient function)
  19. [sE, dir]= imgradient(color);
  20.  
  21. %i Perform watershed transform
  22. watIm=watershed(sE);
  23.  
  24. %Create an image with watershed lines (for statement)
  25. out=img;
  26. for x=1:size(out,1)
  27.     for y= 1:size(out,2)
  28.        if(watIm(x,y)==0)
  29.            out(x,y,1)=255;
  30.            out(x,y,2)=255;
  31.            out(x,y,3)=255;
  32.        end
  33.     end
  34. end
  35.  
  36.  
  37. %Put on the input image the markers
  38. % Compute negative of the markers
  39. %nContours=
  40.  
  41. %Compute products of the nContours image and RGB components of input image (immultiply). Combine them into single colour image
  42. %imgkont(:,:,1)=
  43. %imgkont(:,:,2)=
  44. %imgkont(:,:,3)=
  45.