Rementai

LAB03

Oct 19th, 2022 (edited)
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.75 KB | Source Code | 0 0
  1. clear all;
  2. close all;
  3.  
  4. a = imread("lena1.bmp");
  5. b = imread("lena2.bmp");
  6. c = imread("lena3.bmp");
  7. d = imread("lena4.bmp");
  8. n = 256;
  9.  
  10. figure('Name', 'Lena - histogramy');
  11. subplot(4,2,1);
  12. imshow(a);
  13. subplot(4,2,2);
  14. imhist(a, n);
  15. subplot(4,2,3);
  16. imshow(b);
  17. subplot(4,2,4);
  18. imhist(b, n);
  19. subplot(4,2,5);
  20. imshow(c);
  21. subplot(4,2,6);
  22. imhist(c, n);
  23. subplot(4,2,7);
  24. imshow(d);
  25. subplot(4,2,8);
  26. imhist(d, n);
  27.  
  28. hist1 = imread("hist1.bmp");
  29. rozc = imadjust(hist1);
  30.  
  31. figure('Name', 'Hist1');
  32. subplot(2,2,1)
  33. imshow(hist1)
  34. subplot(2,2,2)
  35. imhist(hist1,256)
  36. subplot(2,2,3)
  37. imshow(rozc)
  38. subplot(2,2,4)
  39. imhist(rozc,256)
  40. %obraz stał sie znacznie bardziej przejrzysty, teraz można dostrzec co tak
  41. %naprawdę kryło się w jakby się mogło wydawać jednym odcieniu szarości
  42.  
  43. [H,x] = imhist(hist1);
  44. c = cumsum(H);
  45. k = max(c)/max(H);
  46. C2=c/k;
  47. figure(3)
  48. subplot(2,2,1)
  49. bar(x,H)
  50. subplot(2,2,2)
  51. plot(c)
  52. subplot(2,2,3)
  53. plot(x,H)
  54. hold on
  55. plot(x,C2)
  56.  
  57. k2 = max(c)/255;
  58. C3=c/k2;
  59. C4=uint8(C3);
  60. lut = intlut(hist1, C4);
  61.  
  62. [H2,x2] = imhist(lut);
  63. F = cumsum(H2);
  64. m = max(F)/max(H2);
  65. F2=F/m;
  66.  
  67. figure(4)
  68. subplot(2,2,1)
  69. imshow(lut)
  70. subplot(2,2,2)
  71. imhist(lut)
  72. subplot(2,2,3)
  73. plot(x2,H2)
  74. hold on
  75. plot(x2,F2)
  76.  
  77. wyr = histeq(hist1,256);
  78. clahe = adapthisteq(hist1);
  79.  
  80. figure(5)
  81. subplot(3,2,1)
  82. imshow(lut)
  83. subplot(3,2,2)
  84. imhist(lut)
  85. subplot(3,2,3)
  86. imshow(wyr)
  87. subplot(3,2,4)
  88. imhist(wyr)
  89. subplot(3,2,5)
  90. imshow(clahe)
  91. subplot(3,2,6)
  92. imhist(clahe)
  93.  
  94.  
  95. hist2 = imread("hist2.bmp");
  96. rozc2 = imadjust(hist2);
  97. hist3 = imread("hist3.bmp");
  98. rozc3 = imadjust(hist3);
  99. hist4 = imread("hist4.jpg");
  100. rozc4 = imadjust(hist4);
  101.  
  102. figure(6)
  103. subplot(2,4,1)
  104. imshow(hist2)
  105. title("Oryginalny")
  106. subplot(2,4,2)
  107. imhist(hist2)
  108. subplot(2,4,3)
  109. imshow(rozc2)
  110. title("Rozciaganie")
  111. subplot(2,4,4)
  112. imhist(rozc2)
  113. subplot(2,4,5)
  114. imshow(histeq(hist2))
  115. title("Wyrównywanie HE")
  116. subplot(2,4,6)
  117. imhist(histeq(hist2))
  118. subplot(2,4,7)
  119. imshow(adapthisteq(hist2))
  120. title("Wyrównywanie CLAHE")
  121. subplot(2,4,8)
  122. imhist(adapthisteq(hist2))
  123.  
  124. figure(7)
  125. subplot(2,4,1)
  126. imshow(hist3)
  127. title("Oryginalny")
  128. subplot(2,4,2)
  129. imhist(hist3)
  130. subplot(2,4,3)
  131. imshow(rozc3)
  132. title("Rozciaganie")
  133. subplot(2,4,4)
  134. imhist(rozc3)
  135. subplot(2,4,5)
  136. imshow(histeq(hist3))
  137. title("Wyrównywanie HE")
  138. subplot(2,4,6)
  139. imhist(histeq(hist3))
  140. subplot(2,4,7)
  141. imshow(adapthisteq(hist3))
  142. title("Wyrównywanie CLAHE")
  143. subplot(2,4,8)
  144. imhist(adapthisteq(hist3))
  145.  
  146. figure(8)
  147. subplot(2,4,1)
  148. imshow(hist4)
  149. title("Oryginalny")
  150. subplot(2,4,2)
  151. imhist(hist4)
  152. subplot(2,4,3)
  153. imshow(rozc4)
  154. title("Rozciaganie")
  155. subplot(2,4,4)
  156. imhist(rozc4)
  157. subplot(2,4,5)
  158. imshow(histeq(hist4))
  159. title("Wyrównywanie HE")
  160. subplot(2,4,6)
  161. imhist(histeq(hist4))
  162. subplot(2,4,7)
  163. imshow(adapthisteq(hist4))
  164. title("Wyrównywanie CLAHE")
  165. subplot(2,4,8)
  166. imhist(adapthisteq(hist4))
  167.  
  168. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=
  169.  
  170. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=
  171.  
  172. clear all;
  173. close all;
  174.  
  175. load histogramZadany;
  176. fobos=imread("phobos.bmp");
  177.  
  178. wyr1=histeq(fobos);
  179. wyr2=histeq(fobos,histogramZadany);
  180. rozc=imadjust(fobos);
  181. CLAHE=adapthisteq(fobos);
  182.  
  183.  
  184. figure;
  185. subplot(2,2,1);
  186. imshow(fobos);
  187. title("Oryginal");
  188. subplot(2,2,2);
  189. imhist(fobos);
  190. subplot(2,2,3);
  191. imshow(wyr1);
  192. title("Histeq");
  193. subplot(2,2,4);
  194. imhist(wyr1);
  195.  
  196. figure;
  197. subplot(2,2,1);
  198. imshow(fobos);
  199. title("Oryginal");
  200. subplot(2,2,2);
  201. imhist(fobos);
  202. subplot(2,2,3);
  203. imshow(wyr2);
  204. title("Histogram Zadany");
  205. subplot(2,2,4);
  206. imhist(wyr2);
  207.  
  208. figure;
  209. subplot(3,2,1);
  210. imshow(fobos);
  211. title("Oryginal");
  212. subplot(3,2,2);
  213. imhist(fobos);
  214. subplot(3,2,3);
  215. imshow(rozc);
  216. title("Imadjust");
  217. subplot(3,2,4);
  218. imhist(rozc);
  219. subplot(3,2,5);
  220. imshow(CLAHE);
  221. title("CLAHE");
  222. subplot(3,2,6);
  223. imhist(CLAHE);
  224.  
Advertisement
Add Comment
Please, Sign In to add comment