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
Ältere Kommentare anzeigen
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');

Antworten (1)
Image Analyst
am 10 Dez. 2013
0 Stimmen
It makes absolutely no sense to do histogram equalization on a binary image.
12 Kommentare
chitresh
am 10 Dez. 2013
Image Analyst
am 10 Dez. 2013
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
am 11 Dez. 2013
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
am 11 Dez. 2013
I know. It's because what you're doing does not make sense.
chitresh
am 14 Dez. 2013
Image Analyst
am 14 Dez. 2013
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
am 14 Dez. 2013
Image Analyst
am 14 Dez. 2013
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
am 16 Dez. 2013
Image Analyst
am 16 Dez. 2013
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.
Kategorien
Mehr zu Display Image finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!