Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clearvars;
- clc;
- %I1 = imread('wyspa.bmp');
- %I1 = imread('kolka.bmp');
- I1 = imread('ertka.bmp');
- SE = strel('square', 3);
- erozja = imerode(I1, SE);
- figure(1);
- subplot(1,2,1);
- imshow(I1);
- title('oryginalny');
- subplot(1,2,2);
- imshow(erozja);
- title('po erozji kwadratem');
- SE2 = strel('diamond', 5);
- erozja2 = imerode(I1, SE2);
- figure(2);
- subplot(1,2,1);
- imshow(I1);
- title('oryginalny');
- subplot(1,2,2);
- imshow(erozja2);
- title('po erozji diamentem');
- erozja22 = imerode(erozja, SE2);
- erozja3 = imerode(erozja22, SE2);
- figure(3);
- subplot(1,3,1);
- imshow(I1);
- title('oryginalny');
- subplot(1,3,2);
- imshow(erozja22);
- title('po erozji 2 razy kwadratem');
- subplot(1,3,3);
- imshow(erozja3);
- title('po erozji 3 razy kwadratem');
- I2 = imread('buzka.bmp');
- ESL = [ 0, 0, 1; 0, 1, 0; 1, 0, 0];
- ELP = [1, 0, 0; 0, 1, 0; 0, 0, 1];
- I2L = imerode(I2, ESL);
- I2P = imerode(I2, ELP);
- figure(4);
- subplot(1,3,1);
- imshow(I2);
- title('oryginalny');
- subplot(1,3,2);
- imshow(I2L);
- title('lewo');
- subplot(1,3,3);
- imshow(I2P);
- title('prawo');
- dylatacja = imdilate(I1, SE);
- figure(5);
- subplot(1,2,1);
- imshow(I1);
- title('oryginalny');
- subplot(1,2,2);
- imshow(dylatacja);
- title('po dylatacji kwadratem');
- figure(6);
- subplot(2,3,1);
- imshow(I1);
- title('oryginalny');
- subplot(2,3,2);
- imshow(erozja);
- title('erozja');
- subplot(2,3,3);
- imshow(dylatacja);
- title('dylatacja');
- subplot(2,3,4);
- imshow(imopen(I1, SE));
- title('otwarcie');
- subplot(2,3,5);
- imshow(imclose(I1, SE));
- title('zamknięcie');
- figure(7);
- subplot(2,1,1);
- imshow(I1);
- subplot(2,1,2);
- imshow(imclose(imopen(I1, SE), SE));
- I3 = imread('hom.bmp');
- SE11 = [0 1 0; 1 1 1; 0 1 0];
- SE22 = [1 0 1; 0 0 0; 1 0 1];
- trans = bwhitmiss(I3, SE11, SE22);
- figure(8);
- subplot(1,2,1);
- imshow(I3);
- title('oryginalny');
- subplot(1,2,2);
- imshow(trans);
- title('po operacji trafił, nie trafił');
- %zad2
- close all;
- clearvars;
- clc;
- I1 = imread('fingerprint.bmp');
- figure(1);
- subplot(2,2,1);
- imshow(I1);
- title('oryginal');
- subplot(2,2,2);
- imshow(bwmorph(I1, 'thin'));
- title('x 1');
- subplot(2,2,3);
- imshow(bwmorph(I1, 'thin', 2));
- title('x 2');
- subplot(2,2,4);
- imshow(bwmorph(I1, 'thin', Inf));
- title('Inf');
- I2 = imread('kosc.bmp');
- figure(2);
- subplot(2,1,1);
- imshow(I2);
- title('oryginal');
- subplot(2,1,2);
- imshow(bwmorph(I2, 'skel', Inf));
- title('Inf');
- I3 = imread('text.bmp');
- MP = ones(51,1);
- otwarcie = imopen(I3, MP);
- SE = strel('square', 3);
- erozja = imerode(I3, SE);
- rekonsturkcja = imreconstruct(erozja,I3);
- figure(3);
- subplot(1,2,1);
- imshow(otwarcie);
- title('samo otwarcie');
- subplot(1,2,2);
- imshow(rekonsturkcja);
- title('po rekonstrukcji');
- wypelnianie = imfill(I3, 'holes');
- czyszczenie = imclearborder(I3);
- figure(4);
- subplot(1,2,1);
- imshow(wypelnianie);
- title('wypelnienie dziur');
- subplot(1,2,2);
- imshow(czyszczenie);
- title('czyszczenie brzegu');
- %zad3
- close all;
- clearvars;
- clc;
- I1 = imread('ferrari.bmp');
- SE = strel('square', 3);
- erozja = imerode(I1, SE);
- dylatacja = imdilate(I1, SE);
- roznica = dylatacja - erozja;
- figure(1);
- subplot(1,3,1);
- imshow(erozja);
- title('erozja');
- subplot(1,3,2);
- imshow(dylatacja);
- title('dylatacja');
- subplot(1,3,3);
- imshow(roznica);
- title('roznica');
- figure(2);
- subplot(2,1,1);
- imshow(imopen(I1, SE));
- title('otwarcie');
- subplot(2,1,2);
- imshow(imclose(I1, SE));
- title('zamknięcie');
- figure(3);
- subplot(2,1,1);
- imshow(imtophat(I1, SE));
- title('top-hat');
- subplot(2,1,2);
- imshow(imbothat(I1, SE));
- title('bottom-hat');
- I2 = imread('rice.png');
- SE2 = strel('disk', 10);
- figure(4);
- subplot(3,1,1);
- imshow(imtophat(I2, SE2));
- title('top-hat');
- subplot(3,1,2);
- imshow(imbothat(I2, SE2));
- title('bottom-hat');
- subplot(3,1,3);
- imshow(I2);
- title('orginalny');
- %zad4
- close all;
- clearvars;
- clc;
- I1 = imread("calculator.bmp");
- line = ones(1,71);
- I2 = imerode(I1, line);
- I3 = imreconstruct(I2, I1);
- I4 = I1 - I3;
- line2 = ones (1,11);
- I5 = imerode(I4, line2);
- line3 = ones (1,21);
- I6 = imdilate(I5, line3);
- I7 = imreconstruct(min(I6, I4), I44);
- figure(1)
- subplot(3,3,1);
- imshow(I1);
- subplot(3,3,2);
- imshow(I2);
- subplot(3,3,3);
- imshow(I3);
- subplot(3,3,4);
- imshow(I4);
- subplot(3,3,5);
- imshow(I5);
- subplot(3,3,6);
- imshow(I6);
- subplot(3,3,7);
- imshow(I7);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement