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

Thread Subject:
How to extract features from medical images?

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 30 Apr, 2011 20:48:04

Message: 1 of 20

Hello,

I am working on an image classification project. I have done a lot of work on machine learning and classification but, I’m still a novice in computer vision.

The images i am working with are images of "Acute Lymphoblastic Leukemia cells". There a lot of pictures of them on Google.

In my data set, every image has lots of white cells and one or two blue cells. (mostly just one blue cell)
My project consists f classifying the blue cells.

I really don’t know how to extract features on my images.

Are there functions on MATLAB that i can use to extract features that i am going to use in my classifier?

I don't mind reading some theory first but, i would be nice to know where to start.

Thanks in advance for your help.

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 30 Apr, 2011 21:00:36

Message: 2 of 20

Here's a good place to start:
http://iris.usc.edu/Vision-Notes/bibliography/contentsmedical.html#Medical%20Applications,%20CAT,%20MRI,%20Ultrasound,%20Heart%20Models,%20Brain%20Models

Here's some segmentation tutorials:
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Subject: How to extract features from medical images?

From: jun

Date: 30 Apr, 2011 22:26:04

Message: 3 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <75a252ff-d885-4e5d-bc71-eb7e071afba1@p13g2000yqh.googlegroups.com>...
> Here's a good place to start:
> http://iris.usc.edu/Vision-Notes/bibliography/contentsmedical.html#Medical%20Applications,%20CAT,%20MRI,%20Ultrasound,%20Heart%20Models,%20Brain%20Models
>
> Here's some segmentation tutorials:
> http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Thanks

How can I know the values are the threshold? I am not quite clear about these values and how to use the software. I have downloaded it and had a go with it. When I pointed to a point of the image, for example,"M" of MacDonald's logo, RGB values of (255,255,0) are given. Are these the threshold?

Regards
jun

Subject: How to extract features from medical images?

From: jun

Date: 30 Apr, 2011 22:41:05

Message: 4 of 20

Sorry.. I replied at the wrong post

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 2 May, 2011 06:35:05

Message: 5 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <75a252ff-d885-4e5d-bc71-eb7e071afba1@p13g2000yqh.googlegroups.com>...
> Here's a good place to start:
> http://iris.usc.edu/Vision-Notes/bibliography/contentsmedical.html#Medical%20Applications,%20CAT,%20MRI,%20Ultrasound,%20Heart%20Models,%20Brain%20Models
>
> Here's some segmentation tutorials:
> http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Hello image analyst,

Thank you for the links you gave me.

You sure have given me a lot of things to read. They kept me busy for two days.
I found 2 very interesting papers. MATLAB also has a lot of good example codes.

I have learned that i have to a bit of pre-processing on my images before i extract features.

This is the plan:
Filter the images. eg: Low pass filter
Segmentation. eg: Color-based segmentation
Histogram Equalization

I have started with filtering. I used the Gaussian filter. The filtered images do look cleaner than the original images.

Here is my code:

H = fspecial('gaussian', [3 3], 1); % I'm not sure about this
im_filt = imfilter(im, H);
imshow(im_filt)

I am not sure about the sigma value and the size of the filter. They seem to be giving clearer images though.

Can you please advice. My images are Acute Lymphoblastic Leukemia cells. There are a lot of pictures on google.

Thank you for your words of wisdom in advance :)

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 2 May, 2011 10:19:50

Message: 6 of 20

You just have to do trial and error to find the best value for your
images. They will all do something but which is "best" is your call.

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 4 May, 2011 14:46:05

Message: 7 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <f38d7c1c-8a94-4085-a570-b9bbf11e454b@r20g2000yqd.googlegroups.com>...
> You just have to do trial and error to find the best value for your
> images. They will all do something but which is "best" is your call.

Hello image analyst,

I have encountered a few problems. I also have some unanswered questions.
It will be nice if you could help me with them.

1) When i changed my image to double precision values, it turned into a white image.
Meaning using any threshold segmentation technique is useless, because the all image is almost unicolored.

I also have to calculate the skewness and kurtosis of the image.
The image must be double precission for those. That mean i will have to work with a unicolored image.
What i am doing is this:
im = imread('myImage'); % This displays the right image
im = double(imread('myImage')); % This displays an almost all white image


2) I am working with rgb images. At some point, ihave to change them into gray sclale.
I know what gray scale mean but, what exactly does it mean, when MATLAB changes a rgb image to a graysacle image? What band does it use, the red one, the green one or the blue one?

3) What is the energy of an image. Does that have to do with Parseval theorem?
I read on Google that they use the energy of an image to see how much information was lost during compression of the image.
How do you calculate the energy of an image in MATLAB? I would like to use it as a feature of an image in my image classification algorithm.

Thanks in advance for your words of wisdom.

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 4 May, 2011 15:29:25

Message: 8 of 20

1) use imshow(im, []) because otherwise it assumes your image is in
the range 0-1, which yours is not.

2) It uses a weighted sum, like it says in the help:
rgb2gray converts RGB values to grayscale values by forming a weighted
sum of the R, G, and B components: 0.2989 * R + 0.5870 * G + 0.1140 *
B
If you want a particular color channel instead, do this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);

3) I don't know. I would think it would be something like the sum of
all pixel values. PSNR is commonly used to compare accuracy of
compression/decompression schemes. Maybe you should look into that.

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 4 May, 2011 16:56:05

Message: 9 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7b4d6d7e-774b-4fe1-8609-0938639c1bd1@z13g2000yqg.googlegroups.com>...
> 1) use imshow(im, []) because otherwise it assumes your image is in
> the range 0-1, which yours is not.
>
> 2) It uses a weighted sum, like it says in the help:
> rgb2gray converts RGB values to grayscale values by forming a weighted
> sum of the R, G, and B components: 0.2989 * R + 0.5870 * G + 0.1140 *
> B
> If you want a particular color channel instead, do this:
> % Extract the individual red, green, and blue color channels.
> redChannel = rgbImage(:, :, 1);
> greenChannel = rgbImage(:, :, 2);
> blueChannel = rgbImage(:, :, 3);
>
> 3) I don't know. I would think it would be something like the sum of
> all pixel values. PSNR is commonly used to compare accuracy of
> compression/decompression schemes. Maybe you should look into that.

I have tried this:

im = double(imread('peppers.png'));
imshow(im,[])

This image displayed is however still an almost all white image. And that is the case with all the images i tried.

Is there anything i am doing wrong?

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 4 May, 2011 19:22:16

Message: 10 of 20

Hmmmmm.... strange - it works for grayscale. Must be something about
it being a color image. Try this:

im = im2double(imread('peppers.png'));
imshow(im,[])

However, im is now in the range 0-1, not 0-255 so be aware of that.
But it DOES display properly doing it that way.

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 6 May, 2011 17:28:05

Message: 11 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <4b01f3e4-4555-4de1-a2a4-e3dd41a35d89@d1g2000yqm.googlegroups.com>...
> Hmmmmm.... strange - it works for grayscale. Must be something about
> it being a color image. Try this:
>
> im = im2double(imread('peppers.png'));
> imshow(im,[])
>
> However, im is now in the range 0-1, not 0-255 so be aware of that.
> But it DOES display properly doing it that way.

Hello image analyst,

I have another problem. It would be great if you could help me.

I have images in a file.
The annotation is as follows. The image files are
named with the notation ImXXX_Y.jpg where XXX is a progressive 3-digit
integer and Y is a boolean digit equal to 0.
All images labeled with Y=0 are from for healthy
individuals, and all images labeled with Y=1 are from non-healphy individuals.

example: Im001_1.tif and Im002_1.tif are healphy individuals.
Im131_0.tif and Im132_0.tif are non healphy individuals.

I only know how to read one image with imread('myImage.tif')

What i would like to do is:

1) Read all the images from the database.

2) Put them in a cell so i can query their ids like this: image.id
If this returns 1, the image is from a non healthy individual. if it return 0, the image is
from a healthy individual. I find this a bit hard to do because the ones and zeros
are in the file names.

3) Shuffle them

4) Divide that set of images in two, one for training, one for testing. (This, i can do)

5) When i'm done segmenting them, save them so i can use them in feature selection.

Thank you for you help

Regards,

Herve

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 6 May, 2011 17:56:04

Message: 12 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <4b01f3e4-4555-4de1-a2a4-e3dd41a35d89@d1g2000yqm.googlegroups.com>...
> Hmmmmm.... strange - it works for grayscale. Must be something about
> it being a color image. Try this:
>
> im = im2double(imread('peppers.png'));
> imshow(im,[])
>
> However, im is now in the range 0-1, not 0-255 so be aware of that.
> But it DOES display properly doing it that way.

I forgot to tell you what i tried.
Here it is:

s = sprintf('Im%d%d%d_%d.tif',0,0,1,1);
A = imread(s);

There are two problems here:

1) The image i am trying to read is Im001_1.tif. I have to use %d
three times. Are there other ways to do this? My images are from Im001_X.tif to Im300_X.tif

2) This only works when i am in the same directory as the database.
I tried a few things: A = imread([Database/A]), A = imread('Database/A')
A = imread([Database], A), ...

None of them worked

Thank you for your help

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 6 May, 2011 21:26:22

Message: 13 of 20

You need to create the full file name - path (folder) plus base
filename. Look into the function "fullfile()"

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 7 May, 2011 03:16:04

Message: 14 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7f649348-9c24-455c-beca-bdeaca4ce562@w24g2000yqb.googlegroups.com>...
> You need to create the full file name - path (folder) plus base
> filename. Look into the function "fullfile()"

Hello again Image analyst,

Thank you for your help so far. It is really appreciated.

I have used a different method for the previous problem.
Here it is (I numbered the lines to make it easy to reffer to them)

Method one(I tried two methods):

line 1: Project.Root=strrep(fileparts(fileparts(mfilename('fullpath'))),'\','/');
line 2: Project.ImagePath=[Project.Root '/LeukemiaCellsClassification/Dataset/%s.tif'];
line 3:for i = 1:NumImages
line 4: s = sprintf('Im%d_%d', 1, i); % The '1' here can either be 1 (sick) or 0 (healthy)
line 5: im{1} = imread(sprintf(Project.ImagePath,s));
line 6:end

Nice, hun :)

There is one problem though.
The second 'd' on line 4 can either be 0 or 1.
1 is for cells from sick individuals. 0 is from healthy ones.

I would like to be able to know what image i am reading (sick or healphy)

All i can do for now is import the images, put them in a cell.
After that, i ca'n tell which are sick, which are healthy.


Method two(What mainly changed here are line 2 and 4 of Method one):

Here, i use two loops. One to read in helphy cell images. The other one to read
sick cell images

Here it is:

line01: Project.Root=strrep(fileparts(fileparts(mfilename('fullpath'))),'\','/');

line02: %The two lines below replace line 2 of method one
line03: Project.SickImagePath=[Project.Root '/LeukemiaCellsClassification/Dataset/%s_1.tif'];
line04: Project.HealthyImagePath=[Project.Root '/LeukemiaCellsClassification/Dataset/%s_0.tif'];
line05:
line06: for i = 1:NumImages
line07: s = sprintf('Im%d', i); % This replaces line 4 of method one
line08: im{i} = imread(sprintf(Project.HealthyImagePath,s));
line09: end
line10:
line11: for i = 1:NumImages
line12: s = sprintf('Im%d', i); % This also replaces line 4 of method one
line13: im{i} = imread(sprintf(Project.SickImagePath,s));
line14: end

The problem with method two is that i get an error because i sometime try to read
and image that does not exist. I woul solve this problem by, for example telling
the loop to skip all the sick cell images (for first loop) and read in only healphy
cell images. I unfortunatly don't know how to do that :(

Thanks for you help,

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 7 May, 2011 15:57:44

Message: 15 of 20

To check for existence, just use exist(fullFileName, 'file).

To check for a certain pattern in the filename indicating sick or
healthy, use
strcmpi(fullFileName, '_0') or
strcmpi(fullFileName, '_1')

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 8 May, 2011 07:26:02

Message: 16 of 20

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <68269931-5865-477b-b39e-9a75baf21187@x1g2000yqb.googlegroups.com>...
> To check for existence, just use exist(fullFileName, 'file).
>
> To check for a certain pattern in the filename indicating sick or
> healthy, use
> strcmpi(fullFileName, '_0') or
> strcmpi(fullFileName, '_1')

Hello image analyst,

Thanks for your tips. It was very help helpful.

I have enountered another problem.

Below is a peice of code i found on MATHWORK website. It was written by an image anylist.
Maybe it was you :)

line 01: binaryImage = im2bw(originalImage, ThresholdValue); % Threshold a grayscale image into a black and white image
line 02: binaryImage = imfill(binaryImage, 'holes');
line 03: labeledImage = bwlabel(binaryImage, 8); % Blobs are labelled on this image
line 04: blobMeasurements = regionprops(labeledImage, 'all');
line 05: BlobMean = blobMeasurements(k).MeanIntensity;

The problem with the mathlab version that i have (MATLAB Version 7.4.0.287 (R2007a))is that
i can not use line 05. I really have to use it for selecting the region of interest in my images.
Is there another way to do this in the MATLAB version that i have?

Thanks for your help.

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 8 May, 2011 13:11:22

Message: 17 of 20

Yes, if you looked at my BlobsDemo tutorial, you'll see it in there:
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Here's some snippets:

% Get all the blob properties. Can only pass in originalImage in
version R2008a and later.
blobMeasurements = regionprops(labeledImage, originalImage, 'all');

So you'd not pass in originalImage.
Then:

% Loop over all blobs printing their measurements to the command
window.
for k = 1 : numberOfBlobs % Loop through all blobs.
% Find the mean of each blob. (R2008a has a better way where you can
pass the original image
% directly into regionprops. The way below works for all versions
including earlier versions.)
    thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of
pixels in current blob.
    meanGL = mean(originalImage(thisBlobsPixels)); % Find mean
intensity (in original image!)

etc.

Subject: How to extract features from medical images?

From: Hervé Chubaka Bagalwa

Date: 10 May, 2011 06:06:04

Message: 18 of 20

Hello Image analyst,

I wrote the piece of code below

message = sprintf('Please input an image or a set of images or press cancel to continue');

reply = questdlg(message, 'Input new Images?', 'Yes', 'No', 'No');

if strcmpi(reply, 'Yes')


    directory = uigetdir; % Get the directory

   % Now i want to read- in all the images in the directory above
end

I would like to read-in all the 'tif' images that are in the directory 'directory'.
The problem is that i don't know the names of those files.
It is the user of my program who will give the program a new set of image. Meaning, i might even never know the names of the input images :(

How do i read them if i don't know their names?

1) If they have the extension 'tif'
2) If they have any extension.

Thank your for your help.

Regards,

Herve

Subject: How to extract features from medical images?

From: ImageAnalyst

Date: 10 May, 2011 10:12:50

Message: 19 of 20

Use the dir() function to retrieve all the tif files in that folder.

Subject: How to extract features from medical images?

From: Steven_Lord

Date: 10 May, 2011 15:17:37

Message: 20 of 20



"Herv Chubaka Bagalwa" <hervechubaka@gmail.com> wrote in message
news:iqakkc$b36$1@newscl01ah.mathworks.com...
> Hello Image analyst,
> I wrote the piece of code below
>
> message = sprintf('Please input an image or a set of images or press
> cancel to continue');
>
> reply = questdlg(message, 'Input new Images?', 'Yes', 'No', 'No');
>
> if strcmpi(reply, 'Yes')
>
>
> directory = uigetdir; % Get the directory
>
> % Now i want to read- in all the images in the directory above
> end
>
> I would like to read-in all the 'tif' images that are in the directory
> 'directory'.
> The problem is that i don't know the names of those files. It is the user
> of my program who will give the program a new set of image. Meaning, i
> might even never know the names of the input images :(
>
> How do i read them if i don't know their names?

The Programming section of the newsgroup FAQ includes a question about
processing a sequence of files. That will show you at least one technique to
do what you want.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us