MATLAB Answers


maximum response of an image

Asked by rita
on 13 Nov 2013
Latest activity Edited by rita
on 14 Nov 2013

hello sir .I am new to matlab. I need help. I am working with 10 images I want to find the maximum response of image. ie. I wan to compare each pixel value with all other image and check for the maximum value and then the maximum value is written is written to the new image . for eg if my

image A is


image B is

                    [4 ,1,3

them my maximum response image should be

                     4 3 4]
like this I have to do for 10 images and create a 11th one...this is my own idea can this be possible I have got a code from ua forum ..but that doesnot work for me..
       So far I have tried
                         img_out = zeros(size(img_in,1), size(img_in,2), N);
                      for n=1:10
                      gb = gabor_fn(bw,gamma,psi(1),lambda,theta);
                       theMaxValues(n) = max(gb(:));
                       theta = angle+pi/180;
                         angle= angle + 15;
                     [overallMax, index] = max(theMaxValues);
                     thetaOfMax = theta(index);
                     final_gb = gabor_fn(bw,gamma,psi(1),lambda,thetaOfMax); 


Log in to comment.

2 Answers

Answer by G A
on 13 Nov 2013

You can try a simple code like this:

  B=[4 ,1,3;
  C(B>C)=B(B>C) %and so on
C =
     4     2     3
     6     7     2
     4     3     4


Log in to comment.

Answer by Image Analyst
on 13 Nov 2013
Edited by Image Analyst
on 13 Nov 2013

Try this:

% Declare 10 sample arrays.
A=[	1,2,3;
B=[	4 ,1,3;
image3 = randi(99, [3, 3]);
image4 = randi(99, [3, 3]);
image5 = randi(99, [3, 3]);
image6 = randi(99, [3, 3]);
image7 = randi(99, [3, 3]);
image8 = randi(99, [3, 3]);
image9 = randi(99, [3, 3]);
image10 = randi(99, [3, 3]);
% Stack together into a 3D array.
image3D = cat(3, A, B, image3, image4, image5, image6, image7, image8, image9, image10);
% Find the max along dimension #3.
maxArray = max(image3D, [], 3)


sir!!!!....I just worked with a example and got it how it works...sir I created array of 10 images and I assigned each image to 1 array

                    i.e img_out(:,:,1) = first image
                         img_out(:,:,2) =second image  
when I initialize this it gives me error sayin
???subscripted dimension mismatch    

I found it curious that you had the gabor function like vidya, then you also gave an example that had A, B, and C. But when I gave you a similar example with arbitrarily named image variables, you pointed me back to the gabor code.

Anyway, with your latest code, the first image and second image must both be gray scale, and must both have the same number of rows and columns. Apparently one of more of those criteria are not met. Do this:

whos firstImage
whos secondImage

See what it says are the sizes of each of those images.

oh oh yes!!! I copied d code from youa forum.which was asked by vidya and some ali( I donot know his name ).and we both(vidya) are working with same project in same college.

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!