NORMALISED THE HISTOGRAM OF AN IMAGE.
8 次查看(过去 30 天)
显示 更早的评论
I HAVE AN color RGB image, i convert it in to grey image than find the edges by canny filter now i need to normalised the edge histogram.
5 个评论
DGM
2022-2-8
You're not normalizing the histogram. You're normalizing the image itself. Normalizing the histogram is simply a matter of scaling it (vertically) so that it has some certain (e.g. 1) area. I don't really see how it would apply to image processing, but this thread discusses it:
If you're looking to flatten the histogram, that's what histeq() attempts to do.
回答(2 个)
Image Analyst
2022-2-8
The histogram you gave is that of the image as you have it. You say "i am looking for equall distributionof pixels all over the intensity range ." I'm asking "why?". That is called histogram equalization (not "normalization") and usually is not necessary and gives an image that doesn't look good or natural. I recommend you do not use histogram equalization. It is not needed.
0 个评论
DGM
2022-2-8
编辑:DGM
2022-2-9
Consider the example using histeq()
A = imread('peppers.png');
Ahsi = rgb2hsi(A); % this is from MIMT on File Exchange
Ah = Ahsi(:,:,1)/360; % unit-scale hue channel
Bh = histeq(Ah,256); % flatten the histogram
figure(1)
histogram(Ah); ylim([0 40E3])
figure(2)
histogram(Bh); ylim([0 40E3])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888270/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888275/image.png)
The histogram is definitely flatter, but as @Image Analyst notes, this doesn't do any favors to the image:
% insert equalized hue channel back into A
Brgb = hsi2rgb(cat(3,Bh*360,Ahsi(:,:,2:3)));
figure(1)
imshow(A);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888280/image.jpeg)
figure(2)
imshow(Brgb);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888285/image.jpeg)
Which should be expected in the case of photographic content. This alteration may not be as visually objectionable when applied to non-referential or abstract content in technical contexts.
For what it's worth, this is the same thing done with adapthisteq(). Normally, adapthisteq() is a lot less abusive of content than histeq(), but since you're working on the hue channel, the results are pretty garish either way. Note that the histogram may not be as flat, but it retains continuity.
Bh = adapthisteq(Ah); % use adapthisteq() instead of histeq
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888295/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888300/image.jpeg)
While a single pass of adapthiseq() may not flatten the histogram as much, it can be effectively iterated, unlike histeq(). It might not necessarily be productive to do so, but the histogram can certainly be made flat.
Bh = adapthisteq(Ah);
Bh = adapthisteq(Bh);
Bh = adapthisteq(Bh);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888305/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888310/image.jpeg)
Again, this should be expected. That's what happens when an image is forced to represent hues that were never in it.
Make of this what you will. This isn't a recommendation of these tools or a particular workflow, as I don't really know why you're trying to reshape the hue distribution in the first place.
EDIT:
For what it's worth, MIMT imrecolor() doesn't do too bad. It's not at all intended to be used like this, but it produces a relatively flat histogram with (relatively) moderate impact on visual image quality.
A = imread('peppers.png');
B = permute(hsv(256),[1 3 2]); % this is just a circular primary-secondary sweep
% imrecolor() is part of MIMT (on the File Exchange)
C = imrecolor(B,A,'colormodel','hsly','channels','h','ybins',1);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888380/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888385/image.jpeg)
Again, this could be iteratively applied for a flatter histogram. The damage isn't as rapidly progressive as with adapthisteq().
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888390/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/888395/image.jpeg)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!