Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all, clear all;
- x = imread('obraz.jpeg');
- xcr = x(:,:,1);
- xcg = x(:,:,2);
- xcb = x(:,:,3);
- [histr,a,b] = ihist(xcr,150,100);
- gr = a*xcr+b;
- [histg,a,b] = ihist(xcg,150,100);
- gg = a*xcg+b;
- [histb,a,b] = ihist(xcb,150,100);
- gb = a*xcb+b;
- [hist2r,a2,b2] = ihist(gr,256,1);
- g2r = uint8(a2*double(gr)+double(b2));
- [hist2g,a2,b2] = ihist(gg,256,1);
- g2g = uint8(a2*double(gg)+double(b2));
- [hist2b,a2,b2] = ihist(gb,256,1);
- g2b = uint8(a2*double(gb)+double(b2));
- [hist3r,a,b] = ihist(g2r,256,1);
- g3r = uint8(a2*double(g2r)+double(b2));
- [hist3g,a,b] = ihist(g2g,256,1);
- g3g = uint8(a2*double(g2g)+double(b2));
- [hist3b,a,b] = ihist(g2b,256,1);
- g3b = uint8(a2*double(g2b)+double(b2));
- [xr, hist4r, vc]=jmequal(g2r);
- [xg, hist4g, vc]=jmequal(g2g);
- [xb, hist4b, vc]=jmequal(g2b);
- figure();
- subplot(4,1,1);
- hold on;
- plot(histr,'r');
- plot(histg,'g');
- plot(histb,'b');
- title('Histogram oryginalnego obrazu')
- subplot(4,1,2);
- hold on;
- plot(hist2r,'r');
- plot(hist2g,'g');
- plot(hist2b,'b');
- title('Histogram zwezonego obrazu')
- subplot(4,1,3);
- hold on;
- plot(hist3r,'r');
- plot(hist3g,'g');
- plot(hist3b,'b');
- title('Histogram rozciagnietego obrazu')
- subplot(4,1,4);
- hold on;
- plot(hist4r,'r');
- plot(hist4g,'g');
- plot(hist4b,'b');
- title('Histogram wyrownanego obrazu')
- figure()
- imagesc(x);
- title('obraz oryginalny')
- figure()
- g(:,:,1)=gr;
- g(:,:,2)=gg;
- g(:,:,3)=gb;
- title('obraz ze zwezonym histogramem')
- imagesc(g);
- figure()
- g2(:,:,1)=g2r;
- g2(:,:,2)=g2g;
- g2(:,:,3)=g2b;
- imagesc(g2);
- title('obraz z rozciagnietym histogramem')
- figure()
- x(:,:,1)=xr;
- x(:,:,2)=xg;
- x(:,:,3)=xb;
- imagesc(x);
- title('obraz z wyrownanym histogramem')
- x = g;%imread('obraz.jpeg');
- hsv = rgb2ycbcr(x);
- hsvl = hsv(:,:,1);
- hsvcr = hsv(:,:,2);
- hsvcb = hsv(:,:,3);
- [hsvl,histr1,vc] = jmequal(hsvl);
- %
- % [hsvcr,histr2,vc] = jmequal(hsvcr);
- %
- % [hsvcb,histr3,vc] = jmequal(hsvcb);
- hold on;
- %x = uint8(x);
- % hsv = double(hsv);
- hsv = hsv;
- x(:,:,3)=hsvcb;
- x(:,:,2)=hsvcr;
- x(:,:,1)=hsvl;
- result = ycbcr2rgb(x);
- %result = uint8(result);
- figure()
- xcr = result(:,:,1);
- xcg = result(:,:,2);
- xcb = result(:,:,3);
- imagesc(result)
- figure()
- [histr,a,b] = ihist(xcr,256,1);
- [histg,a,b] = ihist(xcg,256,1);
- [histb,a,b] = ihist(xcb,256,1);
- hold on;
- plot(histr,'r');
- plot(histg,'g');
- plot(histb,'b');
- title('Histogram wyrównanego obrazu w przestrzeni kolorow YCbCr')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement