Clear Filters
Clear Filters

hi all... i am writing a program to histogram equalize particular bit planes in an image..but i am getting an error in the 1st bit plane..Attempted to access a(241,320); index out of bounds because size(a)=[240,320]. Error in BITPLANE (line 59)

1 view (last 30 days)
clc;
close all;
clear all;
a = imread('F:\TEST PICTURES\car.jpg');
a = rgb2gray(a);
[m n] = size(a);
% to extract 7th bit plane
for i = 1:m
for j = 1:n
b7(i,j) = bitand(a(i,j),128);
end
end
b7o = histeq(b7);
%to extract 6th bit plane
for i = 1:m
for j = 1:n
b6(i,j) = bitand(a(i,j),64);
end
end
b6o = histeq(b6);
%to extract 5th bit plane
for i = 1:m
for j = 1:n
b5(i,j) = bitand(a(i,j),32);
end
end
b5o = histeq(b5);
%to extract 4th bit plane
for i = 1:m
for j = 1:n
b4(i,j) = bitand(a(i,j),16);
end
end
b4o = histeq(b4);
%to extract 3rd bit plane
for i = 1:m
for j = 1:n
b3(i,j) = bitand(a(i,j),8);
end
end
b3o = histeq(b3);
%to extract 2nd bit plane
for i = 1:m
for j = 1:n
b2(i,j) = bitand(a(i,j),4);
end
end
b2o = histeq(b2);
%to extract 1st bit plane
for i = 1:m
for i = 1:n
b1(i,j) = bitand(a(i,j),2);
end
end
b1o = histeq(b1);
%to extract 0th bit plane
for i = 1:m
for j = 1:n
b0(i,j) = bitand(a(i,j),1);
end
end
b0o = histeq(b0);
cc = 2*(2*(2*(2*(2*(2*(2*b7o+b6o)+b5o)+b4o)+b3o)+b2o)+b1o)+b0o;
figure, imshow(cc)

Accepted Answer

Walter Roberson
Walter Roberson on 3 Apr 2014
You miscoded
for i = 1:n
instead of
for j = 1:n
  7 Comments
Walter Roberson
Walter Roberson on 1 Mar 2016
LH and HH is typically notation for floating point coefficients associated with wavelets. If that is the case for you then bitget will not work. But if your LH and HH are integers it will (might need to be nonnegative)
Maneesh Mande
Maneesh Mande on 1 Mar 2016
They are floating point as you suspected and contains negative values too...In this case how do I break them in to bit planes?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!