Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global IPD_PATH;
- RGB = ReadImage(IPD_PATH + 'demos\teaset.png');
- Image = RGB2Gray(RGB);
- //Metoda globalna - binaryzacja z ustalonym progiem
- //LUT = zeros(1,256);
- //a = 169;
- //
- //for i=1:256
- // if i<a then
- // LUT(i) = 0; //false
- // else
- // LUT(i) = 255; //true
- // end
- //end
- //
- //Image(:,:) = LUT(Image(:,:));
- //Metoda lokalna - algorytm bernsena
- //Image = Image(100:300,100:300)
- //
- //[h,w] = size(Image);
- //Image2 = zeros(h,w);
- //
- //for i=2:(h-1)
- // for j=2:(w-1)
- // Wmax = max(Image(i-1:i+1,j-1:j+1))
- // Wmin = max(Image(i-1:i+1,j-1:j+1))
- //
- // prog = double(Wmin+Wmax)/2;
- //
- // if Image(i,j) < prog then
- // Image2(i,j) = 0;
- // else
- // Image2(i,j) = 255;
- // end
- // end
- //end
- //Metoda lokalna - algoryrtm White-Rohrera
- Image = Image(100:300,100:300)
- [h,w] = size(Image);
- Image2 = zeros(h,w);
- k = 1.01;
- for i=2:(h-1)
- for j=2:(w-1)
- srednia = mean(double(Image(i-1:i+1,j-1:j+1)))
- prog = double(srednia)/k;
- if Image(i,j) < prog then
- Image2(i,j) = 0;
- else
- Image2(i,j) = 255;
- end
- end
- end
- h = CreateHistogram(Image2);
- plot(h);
- figure();
- ShowImage(Image2, "Obraz");
Add Comment
Please, Sign In to add comment