Distribution of pixel intensity in percentage plot
I am trying to plot the pixel intensity in percentage of a gray scale image. I have done the preprocessing part of scaling and equalization of the gray image.
I know he histogram plot gives the pixel intensity distribution along the Y axis but i want that in percentage.
Any help is appreciated.
The code i used is here
clc;
close all;
clear all;
I=imread('sand5.jpg');
j=rgb2gray(I);
figure,imshow(j);
J=scale_image(j,1);
figure,imshow(J);
K=histeq(J);
figure,imshow(K);
I need the plot for Pixel intensity distribution in percentage VS pixel intensity values(0-255) along x axis for the gray scale image.
You need to compute the histogram
nn = hist( K(:), 0:255 ); % histogram for 0..255 bins
Now nn
counts the number of pixels at each bin. To get the percentage you only need to divide by the total number of pixels ( numel(K)
) and multiply by 100.
figure;
bar( 0:255, nn*numel(K)/100 );
title('pixel intensity distribution (%)');
xlabel('intensity level');
ylabel('%');
链接地址: http://www.djcxy.com/p/15874.html
上一篇: OpenCV:标准化图像的像素值
下一篇: 像素强度在百分比图中的分布