Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- files = dir('C:\Users\Pixel\Desktop\New folder\images\*.jpg'); % Or whatever filter will pick your images
- for k = 1 : length(files)
- im = fullfile(files(k).folder, files(k).name);
- im = imread(im);
- I= im;
- Red = I(:,:,1);
- Green = I(:,:,2);
- Blue = I(:,:,3);
- %I = I(:); % Vectorization of RGB values
- p = imhist(Red); % Histogram
- p(p == 0) = [ ];% remove zero entries in p
- p = p ./ numel(I); % normalize p so that sum(p) is one.
- Er = round(-sum(p.*log2(p)),3);
- p = imhist(Blue); % Histogram
- p(p == 0) = [ ];% remove zero entries in p
- p = p ./ numel(I); % normalize p so that sum(p) is one.
- Eb = round(-sum(p.*log2(p)),3);
- end
- percentage = sum(Er > Eb) / numel(Er) * 100; % Percentage of images with red entropy higher than blue entropy
- disp(['Percentage of images with red entropy higher than blue entropy: ' num2str(percentage)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement