- close all;
- clear all;
- ertka = imread("ertka.bmp");
- se1 = strel('square', 3);
- se2 = strel('line',10, 45);
- se3 = strel('diamond',3);
- ertkaErozja1 = imerode(ertka,se1);
- ertkaErozja11 = imerode(ertkaErozja1,se1);
- ertkaErozja111 = imerode(ertkaErozja11,se1);
- ertkaErozja2 = imerode(ertka,se2);
- ertkaErozja3 = imerode(ertka,se3);
- figure(1);
- subplot(1,4,1);
- imshow(ertka);
- title("obraz oryginalny");
- subplot(1,4,2);
- imshow(ertkaErozja1);
- title("obraz po erozji kwadrat 3x3");
- subplot(1,4,3);
- imshow(ertkaErozja2);
- title("obraz po erozji linia 10, kąt 45");
- subplot(1,4,4);
- imshow(ertkaErozja3);
- title("obraz po erozji diament 3");
- figure(2);
- subplot(1,3,1);
- imshow(ertkaErozja1);
- title("obraz po jednej erozji kwadrat 3x3");
- subplot(1,3,2);
- imshow(ertkaErozja11);
- title("obraz po dwóch erozji");
- subplot(1,3,3);
- imshow(ertkaErozja111);
- title("obraz po trzech erozjach");
- sebuska = [0 0 0;0 1 1; 0 0 0];
- buska = imread("buska.bmp");
- figure(3);
- subplot(1,2,1);
- imshow(buska)
- title("obraz oryginalny")
- buskaErozja = imerode(buska,sebuska);
- subplot(1,2,2);
- imshow(buskaErozja)
- title("obraz po erozji")
- figure(4);
- ertkaDylatacja = imdilate(ertka,se1);
- imshow(ertkaDylatacja);
- ertkaOpen = imopen(ertka,se1);
- ertkaClose = imclose(ertka,se1);
- imshow(ertkaDylatacja);
- figure(5);
- subplot(3,2,1);
- imshow(ertka);
- title("obraz oryginalny")
- subplot(3,2,2);
- imshow(ertkaErozja1);
- title("Erozja")
- subplot(3,2,3);
- imshow(ertkaDylatacja);
- title("Dylatacja")
- subplot(3,2,4);
- imshow(ertkaOpen);
- title("Open")
- subplot(3,2,5);
- imshow(ertkaClose);
- title("close")
- subplot(3,2,6);
- imshow(imclose(ertkaOpen,se1));
- title("open a potem close")
- hom = imread("hom.bmp");
- figure(6);
- subplot(2,1,1);
- imshow(hom);
- subplot(2,1,2);
- SE11= [ 0 1 0; 1 1 1; 0 1 0];
- SE22= [ 1 0 1; 0 0 0; 1 0 1];
- homBWHitMiss = bwhitmiss(hom,SE11,SE22);
- imshow(homBWHitMiss);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- close all; clear all;
- fingerprint = imread("fingerprint.bmp");
- figure(1);
- FPthin1 = bwmorph(fingerprint,'thin');
- FPthin2 = bwmorph(FPthin1,'thin');
- FPthin3 = bwmorph(FPthin2,'thin');
- FPthin4 = bwmorph(FPthin3,'thin');
- FPthinInf = bwmorph(FPthin1,'thin',Inf);
- subplot(2,3,1);
- imshow(fingerprint);
- title("oryginalny")
- subplot(2,3,2);
- imshow(FPthin1);
- title("FPthin raz")
- subplot(2,3,3);
- imshow(FPthin2);
- title("FPthin 2 razy")
- subplot(2,3,4);
- imshow(FPthin3);
- title("FPthin 3 razy")
- subplot(2,3,5);
- imshow(FPthin4);
- title("FPthin 4 razy")
- subplot(2,3,6);
- imshow(FPthinInf);
- title("FPthin Inf")
- kosc = imread("kosc.bmp");
- figure(2);
- imshow(kosc);
- SpookyScarySkeleton = bwmorph(kosc,'skel',Inf);
- figure(3);
- imshow(SpookyScarySkeleton)
- tekst = imread("text.png");
- SE = ones(51,1);
- tekstOpen = imopen(tekst,SE);
- figure(4);
- subplot(3,1,1);
- imshow(tekst)
- subplot(3,1,2);
- imshow(tekstOpen);
- subplot(3,1,3);
- Wynik = imreconstruct(tekstOpen,tekst);
- imshow(Wynik);
- figure(5);
- WynikFill = imfill(tekst,'holes');
- imshow(WynikFill);
- figure(6);
- subplot(2,1,1)
- imshow(tekst);
- subplot(2,1,2)
- WynikClear = imclearborder(tekst);
- imshow(WynikClear);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- close all;
- clear all;
- ferrari = imread("ferrari.bmp");
- se1 = strel('square', 3);
- ferrariErozja = imerode(ferrari,se1);
- ferrariDylatacja = imdilate(ferrari,se1);
- ferrariabsdiff = imabsdiff(ferrariErozja,ferrariDylatacja);
- subplot(2,2,1);
- imshow(ferrari);
- title("obraz oryginalny");
- subplot(2,2,2);
- imshow(ferrariErozja);
- title("po erozji");
- subplot(2,2,3);
- imshow(ferrariDylatacja);
- title("po dylatacji");
- subplot(2,2,4);
- imshow(ferrariabsdiff);
- title("różnica");
- figure(2);
- subplot(2,1,1);
- ferrariopen = imopen(ferrari,se1);
- imshow(ferrariopen);
- title("imopen");
- subplot(2,1,2);
- ferrariclose = imclose(ferrari,se1);
- imshow(ferrariclose);
- title("imclose");
- ferraritophat = imtophat(ferrari,se1);
- ferraribothat = imbothat(ferrari,se1);
- figure(3);
- imshow(ferraritophat);
- title('top-hat');
- %%Operacja Top-Hat wydobywa małe elementy z obrazów czy też naprawia oświetlenie
- %%Wykonuje imopen a następnie odejmuje obraz oryginalny od wyniku.
- %%Bottom hat, to samo tylko z funkcja imclose. Poprawia kontrast.
- figure(4);
- imshow(ferraribothat);
- title('bottom-hat');
- se2 = strel('disk', 10);
- rice = imread("rice.png");
- figure(5);
- subplot(2,1,1);
- imshow(rice);
- riceTopHat = imtophat(rice,se2);
- subplot(2,1,2);
- imshow(riceTopHat);
- %oświetlenie stało się jednorodne
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- clear all;
- close all;
- calc = imread("calculator.png");
- figure(1);
- imshow(calc);
- ce1 = ones(1,71);
- calcErozja = imerode(calc,ce1);
- calcReconst = imreconstruct(calcErozja,calc);
- figure(2);
- subplot(1,2,1);
- imshow(calcReconst);
- title("otwarcie przez rekonstreukcje");
- subplot(1,2,2);
- calcopen = imopen(calc,ce1);
- imshow(calcopen);
- title("otwarcie klasyczne");
- %otwarcie przez rekonstrukcje zwraca nam całe kształty, nie same kreski.
- figure(3);
- wynikimabsdiff = imabsdiff(calc,calcReconst);
- imshow(wynikimabsdiff);
- figure(4);
- tophat = imtophat(calc,ce1);
- imshow(tophat);
- ce2 = ones(1,11);
- calcErozja2 = imerode(wynikimabsdiff,ce2);
- calcReconst2 = imreconstruct(calcErozja2,wynikimabsdiff);
- figure(5);
- imshow(calcReconst2);
- dylatacja = imdilate(calcReconst2,ones(1,21));
- wynikkoncowy = imreconstruct(min(dylatacja,wynikimabsdiff),wynikimabsdiff);
- figure(6);
- imshow(wynikkoncowy);
- figure(7);
- wynikkoncowy2 = im2bw(wynikkoncowy,0.30);
- wynikkoncowy2 = medfilt2(wynikkoncowy2,[4 4]);
- imshow(wynikkoncowy2);
- title("bonus")
- %udało się uzyskać ekstrakcje pożądanych napisów.