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');

Answers (1)

It makes absolutely no sense to do histogram equalization on a binary image.

12 Comments

can you explain me why, why it dosnt make any sense to you
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.
search an IEEE paper with this name, Bit Planes Histogram Equalization for Tone Mapping of High Contrast Images.
and my question is why cant i see my image and is it posible or someother way to see it, not about its worthwhile , takcare have a good day
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);
nothing new image is still not visible and almost same code just change in paremeters :-(
I know. It's because what you're doing does not make sense.
i ask you read that ieee paper that make you fell what it make sense and i am solved my self what i want thanks you ur views , now can you tell me the formula to calculte brightness and contrast of an image
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(:)));
can you tell me why std deviation for contrast.. and how we can calculate luminance difference of a gray image and average luminance of gray image
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.
link any paper or book which defines your formula or defination
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.

Sign in to comment.

Asked:

on 10 Dec 2013

Commented:

on 16 Dec 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!