SHARE
TWEET

Untitled

a guest Dec 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function secondTask(file)
  2.  
  3.     % чтение изображения
  4.     [original] = readFile(file);
  5.    
  6.     % запись в консоль типа изображения
  7.     sprintf(define_image(file))
  8.    
  9.     [image2, image3, image4] = contrast(rgb2gray(original));
  10.     show(original, image2, image3, image4, noise(rgb2gray(original)), filter(nIimage));
  11.    
  12.     % функция создании гистограммы серого изображения
  13.     gistogram(rgb2gray(original));
  14.    
  15.     writeFile(image2, image3, image4, noise(rgb2gray(original)), filter(nIimage));
  16.     [m1, m2, m3, m4, m5, m6] = findMean(original, image_2, image_3, image_4, n_image, filtered_image);
  17.     [s1, s2, s3, s4, s5, s6] = findStd(original, image_2, image_3, image_4, n_image, filtered_image);
  18.     [c1, c2, c3] = findCorr(image_2, image_3, image_4, n_image, filtered_image);
  19.    
  20.         function image = readFile(file)
  21.         image = imread(file);
  22.     end
  23.    
  24.     function writeFile(image_2, image_3, image_4, n_image, f_image)
  25.         imwrite(image_2, 'EdittedImage1.bmp');
  26.         imwrite(image_3, 'EdittedImage2.bmp');
  27.         imwrite(image_4, 'EdittedImage3.bmp');
  28.         imwrite(n_image, 'EdittedImage4.bmp');
  29.         imwrite(f_image, 'EdittedImage5.bmp');
  30.     end
  31.  
  32.     function show(image, image_2, image_3, image_4, n_image, f_image)
  33.         subplot(4,3,1);
  34.         imshow(image)
  35.         title('Original');
  36.        
  37.         subplot(4,3,2);
  38.         imshow(image_2)
  39.         title('Changed 1');
  40.        
  41.         subplot(4,3,3);
  42.         imshow(image_3)
  43.         title('Changed 2');
  44.        
  45.         subplot(4,3,4);
  46.         imshow(image_4)
  47.         title('Changed 3');
  48.        
  49.         subplot(4,3,5);
  50.         imshow(f_image)
  51.         title('Filter');
  52.        
  53.         subplot(4,3,6);
  54.         imshow(n_image)
  55.         title('Noise');
  56.        
  57.        
  58.     end
  59.  
  60.     function type = define_image(file)
  61.         f = imfinfo(file);
  62.         im_type = f.ColorType;
  63.         if strcmp(im_type,'indexed')
  64.             type = ' indexed ';
  65.         end
  66.         if strcmp(im_type,'grayscale')
  67.             type = ' gray scale ';
  68.         end
  69.         if strcmp(im_type,'truecolor')
  70.             type = ' truecolor ';
  71.         end
  72.        
  73.     end
  74.  
  75.     function [image_2,image_3,image_4] = contrast(image_1)
  76.         image_2 = imadjust(image_1, [0 0.9], [0 0.7], 1);
  77.         image_3 = imadjust(image_1, [0 0.9], [], 0.5);
  78.         image_4 = imadjust(image_1, [0 0.9], [], 2);
  79.     end
  80.     function gistogram(image_1)
  81.          subplot(4,3,8);
  82.          imhist(image_1);
  83.          title('Histogramm');
  84.     end
  85.    
  86.     function n_image = noise(image_1)
  87.          n_image = imnoise(image_1,'speckle');      %добавление шума
  88.     end
  89.    
  90.     function f_image = filter(n_image)
  91.          med = @(n_image) median(n_image(:));       %добавление фильтра
  92.          f_image = nlfilter(n_image,[3 3],med);
  93.     end
  94.  
  95.     function [m1, m2, m3, m4, m5, m6] = findMean(image, image_2, image_3, image_4, n_image, f_image)
  96.         fprintf('Find mean:')
  97.         m1 = mean2(image)
  98.         m2 = mean2(image_2)
  99.         m3 = mean2(image_3)
  100.         m4 = mean2(image_4)
  101.         m5 = mean2(n_image)
  102.         m6 = mean2(f_image)  
  103.     end
  104.    
  105.     function [s1, s2, s3, s4, s5, s6] = findStd(image, image_2, image_3, image_4, n_image, f_image)
  106.         fprintf('Find standart deviation:')
  107.         s1 = std2(image)
  108.         s2 = std2(image_2)
  109.         s3 = std2(image_3)
  110.         s4 = std2(image_4)
  111.         s5 = std2(n_image)
  112.         s6 = std2(f_image)  
  113.     end
  114.    
  115.     function [c1, c2, c3] = findCorr(image_2, image_3, image_4, n_image, f_image)
  116.         fprintf('Find correlation:')
  117.         c1 = corr2(n_image,n_image) %изображения одинаковые => с1 = 1
  118.         c2 = corr2(image_2,image_3) %изображения разные => c2 < 1
  119.         c3 = corr2(n_image,f_image) %изображения разные => c2 < 1
  120.     end
  121.    
  122. end
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