NORMALISED THE HISTOGRAM OF AN IMAGE.
조회 수: 7 (최근 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])
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);
figure(2)
imshow(Brgb);
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
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);
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);
Again, this could be iteratively applied for a flatter histogram. The damage isn't as rapidly progressive as with adapthisteq().
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!