To find energy of each pixel from an image

Hi...iI have two images: one is original image(input image) another is gradient image. Then I found energy of each pixel from the gradient image using the formula E=R^2+G^2+B^2.
Then I want to find max energy for that I used code E_max=max(max(E));
only those pixels whose energy larger than a predefined percentage of E_max want to be selected...the threshold values 90%, 80%, 70% from E_max were used for testing....then the pixels which passed the X% threshold were retained from the original image...
I=original image
GP=gradient image.^2; % for finding energy
E_max=max(max(GP)); % for finding max energy
T=0.8*E_max; % 80% threshold of max energy
index=find(GP>T);
for k=1:size(index,1)
gradient(index(k,1))=i((index(k,1)));
end
whether I have done correctly???? I'm not sure about this... plz give some suggestions

1 Comment

plz any one help me.. whether the above code is correct or not???

Sign in to comment.

Answers (1)

The image itself is the energy so I'm not sure why you have that definition. But anyway, your code does what you say up until you get to the find() line. T is your binary mask image of what pixels meet that criteria. But I don't really know what you want to do after that. What does "retain" mean to you? If you just want a 1D vector of all pixels from the original image meeting that criteria, you can do
thePixels1D = originalImage(T);
if you want to zero out pixels notmeeting that criteria, and get a 2D image with other pixels intact, you can do
outputImage = originalImage; % Make copy of original.
outputImage(~T) = 0; % Blacken pixels not meeting criteria.

4 Comments

retain means replacing the pixels which meets that criteria in the original image
retain means keep. keep and replace are opposites. Please explaing what you want to do. You have in input image. Then you have a binary image that maps out which pixels meet and do not meet your criteria. And you have an output image. What do you want in your output image in the regions that meet the criteria, and for which your binary image is true? What do you want in your output image in the regions that do not meet the criteria, and for which your binary image is false? Please explain clearly this time.
ya I have to keep only that pixels which meet that criteria in the original image...thanks for your help..
I thought I already answered this when I said:
if you want to zero out pixels notmeeting that criteria, and get a 2D image with other pixels intact, you can do
outputImage = originalImage; % Make copy of original.
outputImage(~T) = 0; % Blacken pixels not meeting criteria.
If this isn't what you want, then please explain why this not what you want.

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Tags

Asked:

on 14 Feb 2013

Community Treasure Hunt

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

Start Hunting!