Advertisement
Guest User

entropy

a guest
Jul 16th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. files = dir('C:\Users\Pixel\Desktop\New folder\images\*.jpg'); % Or whatever filter will pick your images
  2. for k = 1 : length(files)
  3. im = fullfile(files(k).folder, files(k).name);
  4. im = imread(im);
  5. I= im;
  6. Red = I(:,:,1);
  7. Green = I(:,:,2);
  8. Blue = I(:,:,3);
  9.  
  10. %I = I(:); % Vectorization of RGB values
  11. p = imhist(Red); % Histogram
  12. p(p == 0) = [ ];% remove zero entries in p
  13. p = p ./ numel(I); % normalize p so that sum(p) is one.
  14. Er = round(-sum(p.*log2(p)),3);
  15.  
  16. p = imhist(Blue); % Histogram
  17. p(p == 0) = [ ];% remove zero entries in p
  18. p = p ./ numel(I); % normalize p so that sum(p) is one.
  19. Eb = round(-sum(p.*log2(p)),3);
  20.  
  21. end
  22.  
  23. percentage = sum(Er > Eb) / numel(Er) * 100; % Percentage of images with red entropy higher than blue entropy
  24.  
  25. disp(['Percentage of images with red entropy higher than blue entropy: ' num2str(percentage)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement