AnAriyan

basic image processing code

Nov 19th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.29 KB | None | 0 0
  1.  
  2.  
  3. % A=zeros([3,3])
  4. % % a=0;b=500;
  5. % % A=a+(b-a)*randn(500,500);
  6. % figure,imshow(A);
  7. %
  8. % a=[1 2 3 4 5 6 7 8 9]
  9. % b=a+2
  10. % plot(b)
  11. % grid on
  12. % plot(b,'*')
  13. % axis([0 10 0 10])
  14. %
  15. % n=10
  16. % a=rand(n)
  17. % A=imagesc(a)
  18. % colormap(gray)
  19. % axis square
  20. %
  21. % b = inv(a)
  22. % imagesc(b);
  23. % c=a*b
  24. % imagesc(c);
  25. % axis square
  26.  
  27. % A=[ 1 2 0 ; 2 5 -1; 4 10 -1]
  28. % B=A'
  29. % c=A*B
  30. % C=A.*B
  31. % eig(A)
  32. % svd(A)
  33.  
  34. % t=(100:10:200)'
  35. % n = length(t)
  36. % [r c]=size(t)
  37.  
  38.  
  39. % A= magic(4)
  40. % A(4,2)
  41. % sum(A(1:4,4))
  42. % sum(A(:,2))
  43. % B=A;
  44. % B(1:3:16)=-10
  45. % A=5:5:50
  46. % B=[1 3 6 7 10]
  47. % A(B)
  48. % A=[1 2 3;4 5 6; 7 8 9]
  49. % B=logical([0 1 0; 1 0 1; 0 0 1])
  50. % A(B)
  51. % A=rand(5)
  52. % A(A>0.5)=0
  53.  
  54. %
  55. % k=10;
  56. % a=zeros(k,k)
  57. % for m= 1:k
  58. %     for n = 1:k
  59. %         a(m,n)=1/(m+n-1)
  60. %     end
  61. % end
  62. % a
  63.  
  64. % eps=1;
  65. % while(1+eps)>1
  66. %     eps=eps/2;
  67. % end
  68. % eps=eps*2
  69.  
  70. % I= imread('football.jpg');
  71. % imshow(I);
  72. % sum(I);
  73. % j=rand(400,600)
  74. % imwrite(j,'rand_image.jpg');
  75. % [r c] = size(j);
  76. % A =size(j);
  77.  
  78. % m=zeros(2,3);
  79. % v=ones(1,3);
  80. % m=eye(3)
  81. %
  82. % v=[1 2 5]
  83. % v(3)
  84. %
  85. % m   = [1 2 9; 4 5 6]
  86. % m(1,3);
  87. % m(2,:);
  88. % m(1,:);
  89. % m(:,1);
  90. % m(:,2);
  91. % size(m);
  92. % size(m,1);
  93. % size(m,2);
  94. % m1=zeros(size(m));
  95. % who
  96. % whos
  97.  
  98.  
  99. % a = [1 2 3 4]
  100. % b=[5 6 7 8]
  101. % a .^ 2;
  102. % a.*b
  103. % c=a./b
  104. % round(c)
  105.  
  106. % a   = [1 4 6 3]
  107. % sum(a)
  108. % mean(a)
  109. % var(a)
  110. % std(a)
  111. % max(a)
  112. % a   = [1 2 3; 4 5 6]
  113. % a(:)
  114. % mean(a)
  115. % max(a)
  116. % max(max(a))
  117. % max(a(:))
  118.  
  119. % v   = [3 5 -2 5 -1 0]  ;     % 1: FOR LOOPS
  120. % u   = zeros( size(v) );     % initialize
  121. % size(v,6);
  122. % for i = 1:size(v,2)         % size(v,2) is the number of columns
  123. %     if( v(i) > 0 )
  124. %         u(i) = v(i);
  125. %     end
  126. % end
  127. % u
  128.  
  129.  
  130. % v   = [3 5 -2 5 -1 0]       % 2: NO FOR LOOPS
  131. % u2  = zeros( size(v) );     % initialize
  132. % ind = find( v>0 )           % index into >0 elements
  133. % u2(ind) = v( ind )  
  134.  
  135.  
  136.  
  137. % figure;                 % matrices as images
  138. % m = rand(64,64);
  139. % imagesc(m)
  140. % colormap gray;
  141. % axis image
  142. % axis off;
  143.  
  144. % [i,map]=imread('trees.tif');
  145. % figure
  146. % imshow(i,map)
  147. % I2=ind2gray(i,map);
  148. % figure
  149. % imshow(I2) ;
  150. %
  151. %  figure
  152. % imagesc(I2,[0 110])      ;                 % scale data to use full colormap
  153. %                                         %  for values between 0 and 1
  154. % colormap('gray')   ;                     % use gray colormap
  155. % axis('image') ;
  156. %
  157. %  I=imread('football.jpg');               % read a JPEG image into 3D array
  158. %  
  159. % figure
  160. % imshow(I)
  161. % rect=getrect;                           % select rectangle
  162. % I2=imcrop(I,rect);                      % crop
  163. % I2=rgb2gray(I2);                        % convert cropped image to grayscale
  164. % figure
  165. % imshow(I2)
  166. % imagesc(I2)  
  167. % figure
  168. % imshow(I2)
  169. %
  170. %
  171. % colormap('gray')
  172. % colorbar                                % turn on color bar
  173. % impixelinfo                             % display pixel values interactively
  174. % truesize                                % display at resolution of one screen pixel
  175. %                                         %  per image pixel
  176. % truesize(3*size(I2))  
  177. %
  178. % I3=imresize(I2,0.5);              % resize by 50% using bilinear
  179. %                                         %  interpolation
  180. % figure
  181. % imshow(I3)
  182.  
  183. % a=imread('football.jpg')
  184. %  imshow(a);
  185. % b=double(a);
  186. % figure
  187. % imshow(b/255);
Advertisement
Add Comment
Please, Sign In to add comment