Hi friends, I want to apply HISTEQ function to an image, but I want that eliminate background(gray-level of 0) befor doing that, how can I do that? plz help me, regards
Emergency need for help about Histeq
Started by ●February 25, 2006
Reply by ●February 28, 20062006-02-28
Hi,
One way to eliminate the background pixels that have a
gray level of 0 would be to convert the 0's into some
other number- for example 255. you can use the find()
function to find all those coordinates that have 0
gray level. once you know the coordinates, set them to
white or mid-gray or anything else. then you can apply
the histeq function on your new image. you can also
loop through the entire image and change the 0's to
something else. You should understand however that the
contents of your image will be changed (as will your
histogram of course).
Use this code:
%----
[r c]=find(img==0)
% r will contain the row coordinate & c will contain
% the column
%------
Or you can use this:
%-------------------------
[m n]=size(img); % to get image dimensions
new_img=img; % Assign the image to a new variable
for i=1:m
for j=1:n
if(img(i,j)==0)
new_img(i,j)%5;
end
end
end
histeq_img=histeq(new_img);
figure,imshow(histeq_img);
%-------------------------
Hope it helps.
E.S
--- reza da <moshtaghtarin@mosh...> wrote:
> Hi friends,
> I want to apply HISTEQ function to an image, but I
> want that eliminate background(gray-level of 0)
> befor doing that, how can I do that?
> plz help me,
> regards
>
>
>
>
>