Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- rice = imread("rice.png");
- katalog = imread("katalog.bmp");
- [X Y] = size(rice);
- obrazBW = rice;
- for i=1:256
- for y=1:256
- srednia(i,y) = meanLT(i,y,7,rice,X,Y);
- if rice(i,y) >= srednia(i,y)
- obrazBW(i,y) = 255;
- else
- obrazBW(i,y) = 0;
- end
- end
- end
- figure(1)
- subplot(1,2,1)
- imshow(rice)
- subplot(1,2,2)
- imshow(obrazBW)
- [X1 Y1] = size(katalog);
- obrazBW2 = katalog;
- for i=1:256
- for y=1:256
- srednia(i,y) = meanLT(i,y,7,katalog,X1,Y1);
- if katalog(i,y) >= srednia(i,y)
- obrazBW2(i,y) = 255;
- else
- obrazBW2(i,y) = 0;
- end
- end
- end
- testU1 = uint8(obrazBW2);
- figure(2)
- subplot(1,2,1)
- imshow(katalog)
- subplot(1,2,2)
- imshow(obrazBW2)
- k = 0.15;
- R = 128;
- obrazBW3 = rice;
- for i=1:1:256
- for y=1:1:256
- srednia = meanLT(i,y,7,rice,X,Y);
- m = stddevLT(i,y,7,rice,srednia,X,Y);
- T(i,y) = srednia * ( 1 - k *((m/R) -1 ));
- if rice(i,y) >= T(i,y)
- obrazBW3(i,y) = 255;
- else
- obrazBW3(i,y) = 0;
- end
- end
- end
- figure(3)
- imshow(obrazBW3)
- obrazBW4 = katalog;
- for i=1:256
- for y=1:256
- srednia = meanLT(i,y,7,katalog,X,Y);
- m = stddevLT(i,y,7,katalog,srednia,X,Y);
- T(i,y) = srednia * ( 1 + k *((m/R) -1 ));
- if katalog(i,y) >= T(i,y)
- obrazBW4(i,y) = 255;
- else
- obrazBW4(i,y) = 0;
- end
- end
- end
- figure(4)
- imshow(obrazBW4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement