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
No products are associated with this question.
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.