MATLAB-Image Processing Help

Discussion in 'Programmer's Corner' started by Sim canada, Feb 20, 2009.

  1. Sim canada

    Thread Starter New Member

    Feb 20, 2009
    1
    0
    Hi everyone,
    I would like to use Matlab to to do image analysis of objects on grayscale images. In short, I have images of metal alloys in grayshades. The variations in shade correspond to a variations in the composition of the alloy (e.g., darker has more Ni, lighter has more Fe, etc...). I would like to study the alloys through image analysis to create compositional domains and study the composition of those compositional domain. I would appreciate some help into how to transform (script, functions) images in Matlab to do so.

    In more details:

    1- I would like to convert the grayscale image (for which pixel have values varying from 0-255) into a simpler image (one which would only have 5-7 shades) by assigning a new value to all pixels belonging to a certain range so I could more efficiently display the different compositional domains on the image. For examples, all pixels with a value between 0-45 would become 0, all pixels from 46-85 would become 50, all pixels from 86-120 would become 100, etc... So, my intensity map with 255 values would become a intensity or colour map with now only 5-7 values which are easily distinguishable from each other.

    2- Second, I would like to be able to do statistics on those pixels. For instance, I would like to be able to calculate the total area covered by all pixels from category 0 (which originally had a value between 0-45), calculate the total area covered by all pixels from category 50 (which originally had a value between 46-85), etc...

    Thanks everyone.
    Cheers,
    Sim.
     
  2. Predictor

    New Member

    Mar 30, 2009
    1
    0
    Let's assume that your ranges are:

    0 - 45 becomes 0
    46 - 85 becomes 1
    86 - 120 becomes 2
    etc.

    It is easy enough to map 0, 1, 2, etc. to 0, 50, 100, etc. later.
    % Assume that 'A' contains the original 0 - 255 image

    % Set the threshold values
    T = [0 46 86 121]; % And so forth...

    % Initialize the mapped image, 'B'
    B = zeros(size(A));

    % Fill in 'B' with mapped values
    for i = 2:m % Loop over all 'm' classes (except the first one)
    % Find and fill the appropriate pixels
    B( A:)) >= T(i) ) = i;
    end
    The second part will require you to locate all "blobs" (individual regions of interest) within the image. I suggest begin by scanning through the image, and flood-filling on each pixel as-yet unclaimed by an existing blob. In other words, start at pixel (1,1), search all neighbors for matches to the class of pixel (1,1): for any neighbors which match, also check their neighbors and so on. Record all pixels in this blob. Scan the image for any pixels not in existing blobs, and repeat. If there aren't any unclaimed pixels left, you've finished the entire image.


    -Will Dwinnell
    Data Mining in MATLAB
     
Loading...