![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207754/image.png)
how to equalize histogram of two images ?
6 ビュー (過去 30 日間)
古いコメントを表示
clc
close all
clear all
img1 = imread('img2.jpg');
img2 = imread('img1.jpg');
subplot(3,2,1);
imshow(img1);
title('First Image');
subplot(3,2,2);
imhist(rgb2gray(img1));
title('histogram of First image');
subplot(3,2,3);
imshow(img2);
title('Second Image');
subplot(3,2,4);
imhist(rgb2gray(img2));
title('histogram of Second image');
% how to equalize the histogram of img1 and img2 ? getting error here
a = histeq(rgb2gray(img1,img2));
subplot(3,2,5);
imshow(a);
title('histogram equalize')
% how to equalize the histogram of img1 and img2 ?
0 件のコメント
採用された回答
Image Analyst
2019 年 3 月 10 日
編集済み: Image Analyst
2019 年 3 月 10 日
You could try imhistmatch(), but as you can see below, it doesn't do such a great job:
testImage = imread('moon.tif');
subplot(2, 3, 1);
imshow(testImage);
refImage = imread('cameraman.tif');
subplot(2, 3, 2);
imshow(refImage);
matchedImage = imhistmatch(testImage, refImage);
subplot(2, 3, 3);
imshow(matchedImage);
% Plot histograms
subplot(2, 3, 4);
imhist(testImage);
subplot(2, 3, 5);
imhist(refImage);
subplot(2, 3, 6);
imhist(matchedImage);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207754/image.png)
If you really want to do it right, you have to employ a few tricks (adding noise, sorting, randomly picking, etc.). I employ these tricks in my File Exchange submission which will match any histogram to any other histogram regardless of the shape.
0 件のコメント
その他の回答 (1 件)
KALYAN ACHARJYA
2019 年 3 月 10 日
編集済み: KALYAN ACHARJYA
2019 年 3 月 10 日
Normally Histogram equalization in one image, I hope you know the objective of hitogram equalization.
If you are trying to do operation on histograms in two images, hopefully it is histogram matching
a=imhistmatch(main_image, referenece_image);
Please note both are gray images.
In histogram matching, it try to make the histogram of main image as histogram of reference image.
If not, let me know the exact question.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!