Thursday, 11 February 2016

Medical Image Processing 1


How To Read CT/MRI  Image Into Matlab ???????.........

Lets , know the basic in brief ..
CT stands for Computed Tomography and is basically a medical image. Normally whenever you capture pictures from your cell phone , it will be in .jpg ,.png etc format. Similarly a standard is followed worldwide and hence  medical images such as CT,MRI,PET etc are captured and stored in DICOM format.(.dcm) DICOM stands for Digital Imaging in Communications and Medicine. 
you can get enough information from the following link :https://en.wikipedia.org/wiki/DICOM

Lets start then,

open your MATLAB , create a new file

your first commands should be
clc;
close all;
clear all;

First command will clear the command window
second command will close any windows left out open
Third  command will clear all the variables declared(if any).

To read medical image in dicom format we use dicom read. you can go to the command window and type help dicomread to get the syntax and usage of the command

An example for reading and displaying dicom image is given below

[a,b]=dicomread('image.dcm');

imshow(a,[]);

when you do the above task image looks like this :



The reason is because MATLAB treats all negative values as zero. Basically Dicom image is 16bit image where 12bits represent image info and 4bit represents textual info. Considering negative values, The pixel value ranges from -2048 to +2047.into visible 256-greyscale range. This linear
intensity windowing, also called as window setting.The standard setting is window
center of 40HU and width of 80 HU which is done as follows

imginfo=dicominfo('image.dcm');
c= imginfo.windowCenter;
w=imginfo.WindowWidth;

check the values , if it is not set to standard values , set it manually
c=double(40);
w=double(80);

The rescaling is done as follows

imgScaled = 255.*((double(a)-(c-0.5))/(w-1)+0.5);
imgScaled = uint8(min(max(imgScaled, 0), 255));

If you display the image it looks like this
imshow(imgScaled)