SHARE
TWEET

Untitled

a guest May 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %%%%%%%% Bwlabel %%%%%%%%%%%%%%
  2. im = imread('C:\Users\octavian.feodot\Desktop\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\etichete\binar1.bmp');
  3. im = double(im);
  4.  
  5. figure,imagesc(im),colormap(gray(256));
  6. im = im/255;
  7. im = not(im);
  8. figure,imagesc(im),colormap(gray(256));
  9.  
  10. im1 = bwlabel(im,4)
  11. figure,
  12. subplot(1,2,1),imagesc(im1),colormap(jet);
  13. subplot(1,2,2),imagesc(bwlabel(im,8)),colormap(jet);
  14.  
  15.  
  16.  
  17. %%%% GrowReg %%%%%%%%%%%%%
  18. img = imread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\LABORATOR-imagini\lena_512.bmp');
  19. img = double(img);
  20. figure, imagesc(img), colormap(gray(256));
  21.  
  22. [sir, sir_val] = grow_reg(img, 104, 446, 50, 10000);
  23. dim = size(sir);
  24.  
  25. cm = gray(256);
  26.  
  27. for i=1:dim(1)
  28.     img(sir(i,1),sir(i,2))=257;
  29. end
  30.  
  31. cm(257,:) = [1 0 0];
  32. figure, image(img), colormap(cm);
  33.  
  34. %%%% Segmentare pe hist %%%%%%%%%%
  35. img = imgread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\artificial\tst1_128', 128);
  36. img = double(img);
  37. figure, imagesc(img), colormap(gray(256));
  38.  
  39. h = hist(double(img(:)),1:256);
  40. figure, plot(h);
  41.  
  42. out=zeros(128);
  43. out(img<25)=0;
  44. out((img>25)&(img<=75))=1;
  45. out((img>75)&(img<=125))=2;
  46. out((img>125)&(img<=175))=3;
  47. out((img>175)&(img<=225))=4;
  48.  
  49. figure,imagesc(out),colormap(gray(256));
  50.  
  51.  
  52.  
  53. %%%% Metode de contur %%%%%%
  54. im = imgread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\natural\lena_256',256);
  55. % im1 = double(im);
  56. figure, image(im), colormap(gray(256))
  57. M = im;
  58. dim = 255;
  59.  
  60. % Gradient
  61. for i=2:dim
  62.         for j=2:dim
  63.             fx=im(i,j) - im(i,j+1);
  64.             fy=im(i,j) - im(i+1,j);
  65.         M(i,j) = sqrt(fx^2 + fy^2);
  66.         end
  67. end
  68.  
  69. figure, imagesc(M), colormap(gray(256)), title('Gradient')
  70.  
  71. % Compas
  72. for i = 2:dim
  73.         for j=2:dim
  74.             D1=abs(im(i,j-1)-(im(i,j+1)));
  75.             D2=abs(im(i-1,j)-(im(i+1,j)));
  76.             D3=abs(im(i-1,j+1)-(im(i+1,j-1)));
  77.             D4=abs(im(i-1,j-1)-(im(i+1,j+1)));
  78.         M(i,j)=max([D1 D2 D3 D4]);
  79.         end
  80. end
  81.  
  82. figure, imagesc(M), colormap(gray(256)), title('Compas')
  83.  
  84.  
  85. %%%% Compactitate forme %%%%%%%%%%
  86. im = imread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\forme\F2.bmp');
  87. figure, image(im), colormap(gray(256))
  88.  
  89. for i=1:256
  90.     for j=1:256
  91.         if im(i,j) == 0
  92.             M(i,j)=0;
  93.         else
  94.             M(i,j)=255;
  95.         end
  96.     end
  97. end
  98. figure, image(M), colormap(gray(256))
  99.  
  100. im = M;
  101.  
  102. for i=2:255
  103.     for j=2:255
  104.         D1=abs(im(i,j-1)-im(i,j+1));
  105.         D2=abs(im(i-1,j)-im(i+1,j));
  106.         D3=abs(im(i-1,j+1)-im(i+1,j-1));
  107.         D4=abs(im(i-1,j-1)-im(i+1,j+1));
  108.     M(i,j) = max([D1 D2 D3 D4]);
  109.     end
  110. end
  111.  
  112. figure, image(M), colormap(gray(256))
  113.  
  114. P=0;
  115.  
  116. for i=1:256
  117.     for j=1:256
  118.         if M(i,j)==255
  119.             P=P+1;
  120.         end
  121.     end
  122. end
  123.  
  124. P = (P-4*255)/2;
  125.  
  126.  
  127.  
  128. A = 0;
  129.  
  130. for i=1:256
  131.     for j=1:256
  132.         if im(i,j)==0
  133.             A=A+1;
  134.         end
  135.     end
  136. end
  137.  
  138. C = (P^2)/(4*pi*A)
  139.  
  140.  
  141.  
  142. %%%% Cooc, izosegmente %%%%%
  143. im1 = imgread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\texturi\t3_256', 256);
  144. im2 = imgread('A:\colocviu_AI\AI_TOT_PT_COLOCVIU\LabPAI\imagini\texturi\t1_256', 256);
  145.  
  146. figure, image(im1), colormap(gray(256));
  147. figure, image(im2), colormap(gray(256));
  148.  
  149. T = [1 1]
  150. co10 = cooc(im1,T);
  151. iz10 = izoseg(im1);
  152. mco10 = mas_cooc(co10);
  153. miz10 = mas_izo(iz10);
  154.  
  155. co20 = cooc(im2,t);
  156. iz20 = izoseg(im2);
  157. mco20 = mas_cooc(co20);
  158. miz20 = mas_izo(iz20);
  159.  
  160. M11 = im;
  161. M12 = rot90(im);
  162. M13 = fliplr(im2);
  163.  
  164. M21 = im;
  165. M22 = rot90(im2);
  166. M23 = fliplr(im2);
  167.  
  168. % patrat 1
  169.  
  170. co11=cooc(M11,T);
  171. iz11=izoseg(M11);
  172. mco11 = mas_cooc(co11);
  173. miz11 = mas_izo(iz11);
  174.  
  175. co21=cooc(M21,T);
  176. iz21=izoseg(M21);
  177. mco21 = mas_cooc(co11);
  178. miz21 = mas_izo(iz11);
  179.  
  180. % patrat 2
  181.  
  182. co12=cooc(M11,T);
  183. iz12=izoseg(M12);
  184. mco12 = mas_cooc(co12);
  185. miz12 = mas_izo(iz12);
  186.  
  187. co22=cooc(M22,T);
  188. iz22=izoseg(M22);
  189. mco22 = mas_cooc(co22);
  190. miz22 = mas_izo(iz22);
  191.  
  192. % patrat 3
  193.  
  194. co13=cooc(M13,T);
  195. iz13=izoseg(M13);
  196. mco13 = mas_cooc(co13);
  197. miz13 = mas_izo(iz13);
  198.  
  199. co23=cooc(M23,T);
  200. iz23=izoseg(M23);
  201. mco23 = mas_cooc(co23);
  202. miz23 = mas_izo(iz23);
  203.  
  204. date_cooc = [mco11; mco12; mco13; mco21; mco22; mco23];
  205. [C,U,J] = fcm(date_cooc,2);
  206.  
  207. date_join = [mco11 miz11; mco12 miz12; mco13 miz13; mco21 miz21; mco22 miz22; mco23 miz23];
  208. [Cj,Uj, Jj] = fcm(date_join,2);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top