when i recombined bit plane image after histogram equalization,it is completely white not visible, can anyone tell me why, i try this code, please help me
이전 댓글 표시
why my reconstruct image is white can anyone tell me i try this code
input = imread('input.jpg');
input_gray = rgb2gray(input);
bit_1 = bitget(input_gray,1);
bit_2 = bitget(input_gray,2);
histeq_1 = histeq(bit_1);
histeq_2 = histeq(bit_2);
reconstruct_image = zeros(size(input_gray));
reconstruct_image = uint8(reconstruct_image);
reconstruct_image = bitset(reconstruct_image,1,histeq_1);
reconstruct_image = bitset(reconstruct_image,2,histeq_2);
figure,imshow(reconstruct_image,[]),title('reconstruct image');

답변 (1개)
Image Analyst
2013년 12월 10일
0 개 추천
It makes absolutely no sense to do histogram equalization on a binary image.
댓글 수: 12
chitresh
2013년 12월 10일
Image Analyst
2013년 12월 10일
Histogram equalization just moves around the intensities - it just remaps one intensity to another. If you have lots of intensities, it can redistribute them within the 0-255 range to new values. But a binary image just has 2 values 0 and 1. Exactly where do you want to put those? And why? How about if everything with 0 gray level now went to 0.3245 and everything with 1 is not at .874234? What good is that? No good.
Look at an actual example:
binaryImage = [false true false true]
hist_eq = histeq(single(binaryImage))
and what it gives:
binaryImage =
0 1 0 1
hist_eq =
0.4920635 1 0.4920635 1
What good is it? It's useless! You can't use that image for anything worthwhile. You were better off with the binary image.
Image Analyst
2013년 12월 11일
It's a uniform image. See my code:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
inputRGB = imread('peppers.png');
subplot(2,4,1);
imshow(inputRGB);
title('Original RGB', 'FontSize', fontSize, 'Interpreter', 'none');
input_gray = rgb2gray(inputRGB);
subplot(2,4,2);
imshow(input_gray);
title('input gray', 'FontSize', fontSize, 'Interpreter', 'none');
drawnow;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
bit_1 = bitget(input_gray,1);
subplot(2,4,3);
imshow(bit_1, []);
title('bit_1', 'FontSize', fontSize, 'Interpreter', 'none');
bit_2 = bitget(input_gray,2);
subplot(2,4,4);
imshow(bit_2, []);
title('bit_2', 'FontSize', fontSize, 'Interpreter', 'none');
histeq_1 = histeq(bit_1);
subplot(2,4,5);
imshow(histeq_1, []);
title('histeq_1', 'FontSize', fontSize, 'Interpreter', 'none');
histeq_2 = histeq(bit_2);
subplot(2,4,6);
imshow(histeq_2, []);
title('histeq_2', 'FontSize', fontSize, 'Interpreter', 'none');
drawnow;
reconstruct_image = zeros(size(input_gray));
reconstruct_image = uint8(reconstruct_image);
reconstruct_image = bitset(reconstruct_image,1,histeq_1);
reconstruct_image = bitset(reconstruct_image,2,histeq_2);
subplot(2,4,7);
imshow(reconstruct_image,[])
title('reconstruct image', 'FontSize', fontSize, 'Interpreter', 'none');
message = sprintf('Min of reconstruct_image = %d.\nMax of reconstruct_image = %d.\n',...
min(reconstruct_image(:)), max(reconstruct_image(:)));
fprintf('%s\n', message);
msgbox(message);
Image Analyst
2013년 12월 11일
I know. It's because what you're doing does not make sense.
chitresh
2013년 12월 14일
Image Analyst
2013년 12월 14일
Well I'm glad you fixed the code. What definition of brightness and contrast would be useful for you? How about the mean of the image for the brightness and the standard deviation for the contrast?
brightness = mean2(grayImage);
contrst = std(double(grayImage(:)));
chitresh
2013년 12월 14일
Image Analyst
2013년 12월 14일
Do you have a better definition? The less stddev, the more uniform the image and the greater the stddev, the wider dynamic range. Seems as good a definition as any but you're free to make up your own if you want.
For the second question
diffImage = double(grayImage) - mean2(grayImage);
Need to cast to double to allow negative differences.
chitresh
2013년 12월 16일
Image Analyst
2013년 12월 16일
It's just common sense so I'm not going to try to find a paper that mentions it. Everybody knows this. The narrow the histogram, the more uniform the image and the wider it is, the more dynamic range and contrast you'll have. It would be like trying to find a paper that says if the mean of a histogram is higher then the intensity is higher - it's just common sense.
카테고리
도움말 센터 및 File Exchange에서 Display Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!