Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////cumulatedHist//////////////////////
- function [H, x, C] = cumulatedHist(hist)
- [H, x] = imhist(hist);
- tmpC = cumsum(H);
- k = max(tmpC)/max(H);
- C = tmpC/k;
- end
- ///////////////////zA//////////////////////////////
- clearvars;
- close all;
- clc;
- %% Read images
- lena1 = imread("lena1.bmp");
- lena2 = imread("lena2.bmp");
- lena3 = imread("lena3.bmp");
- lena4 = imread("lena4.bmp");
- %% create histograms
- hist1 = imread('hist1.bmp');
- hist2 = imread('hist2.bmp');
- hist3 = imread('hist3.bmp');
- hist4 = imread('hist4.bmp');
- %% formatted images
- figure(1);
- subplot(2,4,1);
- imshow(lena1);
- subplot(2,4,5);
- imhist(lena1, 256);
- subplot(2,4,2);
- imshow(lena2);
- subplot(2,4,6);
- imhist(lena2, 256);
- subplot(2,4,3);
- imshow(lena3);
- subplot(2,4,7);
- imhist(lena3, 256);
- subplot(2,4,4);
- imshow(lena4);
- subplot(2,4,8);
- imhist(lena4, 256);
- %% histogram 1
- figure(2);
- subplot(2, 1, 1);
- imshow(hist1)
- subplot(2, 1, 2);
- imhist(hist1, 256);
- %% adjusted histogram 1
- figure(3);
- adjustedHist1 = imadjust(hist1);
- subplot(2,1,1);
- imshow(adjustedHist1);
- subplot(2,1,2);
- imhist(adjustedHist1, 256);
- title("adjusted histogram 1");
- %% cumulated histogram
- [H, x, C2] = cumulatedHist(hist1);
- figure(4);
- subplot(1,2,1);
- imshow(hist1);
- subplot(1,2,2);
- plot(x,H);
- hold on;
- plot(x, C2);
- title('cumulated histogram');
- %% LUT
- lut = uint8(255*(C2/max(C2)));
- [Hlut, xlut] = imhist(intlut(hist1, lut),256);
- tmpC = cumsum(Hlut);
- k = max(tmpC) / max(Hlut);
- Clut = tmpC / k;
- figure(4);
- subplot(4, 1, 1);
- imshow(intlut(hist1, lut));
- title('LUT converted');
- subplot(4,1,2);
- histeq(hist1, 256);
- title('histeq treated');
- subplot(4,1,3);
- plot(xlut, Hlut);
- title('histogram');
- subplot(4,1,4);
- plot(xlut, Clut);
- title('cumulated histogram');
- % hist2 image
- figure(5);
- subplot(4,4,1); imshow(hist2);
- title('null');
- subplot(4,4,2); imshow(imadjust(hist2));
- title('adjusted');
- subplot(4,4,3); imshow(histeq(hist2));
- title('histeq treated');
- subplot(4,4,4); imshow(adapthisteq(hist2));
- title('adapthisteq treated');
- %%
- % hist3 image
- subplot(4,4,5); imshow(hist3);
- subplot(4,4,6); imshow(imadjust(hist3));
- subplot(4,4,7); imshow(histeq(hist3));
- subplot(4,4,8); imshow(adapthisteq(hist3));
- %%
- % hist4 image
- subplot(4,4,9); imshow(hist4);
- subplot(4,4,10); imshow(imadjust(hist4));
- subplot(4,4,11); imshow(histeq(hist4));
- subplot(4,4,12); imshow(adapthisteq(hist4));
- //////////////////////zB////////////////////////////////////
- clearvars;
- close all;
- clc;
- %% Reading images
- lena1 = imread('lena1.bmp');
- lena2 = imread('lena2.bmp');
- lena3 = imread('lena3.bmp');
- lena4 = imread('lena4.bmp');
- phobos = imread('phobos.bmp');
- image = phobos;
- load("histogramZadany");
- figure(1);
- plot(histogramZadany);
- eqImage = histeq(image, histogramZadany);
- figure(2);
- subplot(1,3,1);
- imshow(eqImage);
- title('hiteqd image');
- subplot(1,3,2);
- imhist(image, 256);
- title('histogram');
- subplot(1,3,3);
- adjustedImage = imadjust(eqImage);
- adapted = adapthisteq(adjustedImage, 'clipLimit', 0.02, 'Distribution', 'rayleigh');
- imshow(adapted);
- title('rozciaganie oraz adaptacyjne wyrownanie CLAHE');
- ////////////////////////zC////////////////////////////////////
- clearvars;
- close all;
- clc;
- %% reading images
- lena = imread("lenaRGB.bmp");
- jezioro = imread("jezioro.jpg");
- image = jezioro;
- %% extract rgb
- red = image(:,:,1);
- green = image(:,:,2);
- blue = image(:,:,3);
- figure(1);
- subplot(1,3,1);
- imhist(red, 256);
- title('Red');
- subplot(1,3,2);
- imhist(green, 256);
- title('Green');
- subplot(1,3,3);
- imhist(blue, 256);
- title('Blue');
- %% adjust
- eqImage = image;
- eqImage(:,:,1) = histeq(red, 256);
- eqImage(:,:,2) = histeq(green, 256);
- eqImage(:,:,3) = histeq(blue, 256);
- figure(2);
- imshow(eqImage);
- %% HSV
- hsvImage = rgb2hsv(image);
- h = hsvImage(:,:,1);
- s = hsvImage(:,:,2);
- v = hsvImage(:,:,3);
- figure(3);
- subplot(1,3,1);
- imhist(h, 256);
- title('H');
- subplot(1,3,2);
- imhist(s, 256);
- title('S');
- subplot(1,3,3);
- imhist(v, 256);
- title('V');
- % brightness
- hsvImage(:,:,3) = histeq(v, 256);
- hsvImage = hsv2rgb(hsvImage);
- figure(4);
- subplot(1,2,1);
- imshow(hsvImage);
- title('manipulated');
- subplot(1,2,2);
- imshow(image);
- title('original');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement