views:

38

answers:

1

i have 100 b&w image of smthing.the probllem is i want to scan each image in 0&1 formatin mby n format and then place each image to one over one and again scan and save them in mbynby100 form. how i do this and from where i should start _jaysean

+2  A: 

Your question is vague and hard to understand, but my guess is that you want to take 100 M-by-N grayscale intensity images, threshold them to create logical matrices (i.e. containing zeroes and ones), then put them together into one M-by-N-by-100 matrix. You can do the thresholding by simply picking a threshold value yourself, like 0.5, and applying it to an image A as follows:

B = A > 0.5;

The matrix B will now be an M-by-N logical matrix with ones where A is greater than 0.5 and zeroes where A is less than or equal to 0.5.

If you have the Image Processing Toolbox, you could instead use the function GRAYTHRESH to pick a threshold and the function IM2BW to apply it:

B = im2bw(A,graythresh(A));

Once you do this, you can easily put the images into an M-by-N-by-100 logical matrix. Here's an example of how you could do this in a loop, assuming the variables M and N are defined:

allImages = false(M,N,100);  %# Initialize the matrix to store all the images
for k = 1:100
  %# Here, you would load your image into variable A
  allImages(:,:,k) = im2bw(A,graythresh(A));  %# Threshold A and add it to
                                              %#   the matrix allImages
end
gnovice
I was going to put an answer in lolcode. I guess you have saved me some work :).
Jonas