Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.96 KB | None | 0 0
  1. clc; clear all; close all;
  2.  
  3. a = imread('osteo2.jpg');
  4. b = imcrop(a);
  5. P = impixel(b);
  6. close;
  7.  
  8. [m,n,p] = size(b);
  9.  
  10. Pav = mean(P,1);
  11. imf = (im2double(reshape(b, m*n, 3))).*255;
  12.  
  13. cutoff = .3; % standard deviations
  14.  
  15. q = repmat(Pav,[size(imf,1),1]);
  16.  
  17. % Find the difference from the reference for each [R,G,B]
  18. distance = sum((imf - q).^2, 2);
  19.  
  20. % Figure out cases where the distance is within the cutoff
  21. tf = distance <= cutoff.*std(distance);
  22.  
  23. tra = reshape(tf, m, n);
  24.  
  25. figure(2);
  26. imshow(b);
  27.  
  28. figure(3);
  29. imshow(tra);
  30. %
  31. % minRegionSize = 10
  32. %
  33. % [lbl, num] = bwlabel(tra, 8);
  34. %
  35. % for i=1:max(lbl)
  36. %     if sum (lbl==i) < minRegionSize
  37. %         lbl(lbl==i) = 0;
  38. %     end
  39. % end
  40. %
  41. % num
  42.  
  43. % minRegionSize = 4;
  44. % connStruct = bwconncomp (tra);
  45. % regions = connStruct.PixelIdxList;
  46. %
  47. % ct = 0;
  48. %
  49. % for i=1:connStruct.NumObjects
  50. %     if numel (regions{i-ct}) < minRegionSize
  51. %         regions{i-ct} = []
  52. %         ct = ct+1;
  53. %     end
  54. % end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement