Friday, April 1, 2016

Matlab code to study of lymphocyte and red blood cells

%Matlab Code:
% Author: Minh Anh Nguyen (minhanhnguyen@q.com)
% This script will perform the following tasks:
% Read in a standard MATLAB gray scale demo image.
% perform histogram

clear all; % Erase all existing variables.
close all; % Close all figures (except those of imtool.)
clc;% Clear the command window.
imtool close all; % Close all imtool figures.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
fontSize1 = 14;

Read in a standard MATLAB gray scale demo image.

folder = 'F:\image';
%the image is from this website: http://library.med.utah.edu/WebPath/HEMEHTML/HEME002.html
b = imread('HEME002.jpg'); %% same image

info

 imfinfo('HEME002.jpg')
ans = 

           Filename: 'F:\image\HEME002.jpg'
        FileModDate: '01-Apr-2016 02:00:56'
           FileSize: 85031
             Format: 'jpg'
      FormatVersion: ''
              Width: 504
             Height: 331
           BitDepth: 24
          ColorType: 'truecolor'
    FormatSignature: ''
    NumberOfSamples: 3
       CodingMethod: 'Huffman'
      CodingProcess: 'Sequential'
            Comment: {}

size

 b1= size (b);
figure;
subplot(2,2,1);
imshow(b);
title('Mature lymphocyte with a single large nucleus image', 'Fontsize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% % Get means of Second image
meanredPlane1 = mean2(b(:, :, 1));
meangreenPlane1 = mean2(b(:, :, 2));
meanbluePlane1 = mean2(b(:, :, 3));

redPlane1 = b(:, :, 1);
greenPlane1 =b(:, :, 2);
bluePlane1 = b(:, :, 3);


subplot(2, 2, 2); imagesc (b>45);
colorbar; title('Lymphocyte');
colormap('jet');

 subplot(2, 2, 4); imagesc (redPlane1); title('Red Blood Cell');
 colorbar; colormap('jet');

% Let's get its histograms.
subplot(2, 2, 3); hist(single(b(:)),256);
str1=sprintf('Histogram of Mature lymphocyte with a single large nucleus image', 'Fontsize', fontSize);
title(str1);
xlabel('Intensity values','Fontsize', fontSize1);
ylabel('Number of pixels', 'Fontsize', fontSize1);

CT scan of brain image



 %Matlab Code:
% Author: Minh Anh Nguyen (minhanhnguyen@q.com)
% This script will perform the following tasks:
%Read in a standard MATLAB gray scale demo image.
% perform histogram

clear all; % Erase all existing variables.
close all; % Close all figures (except those of imtool.)
clc;% Clear the command window.
imtool close all; % Close all imtool figures.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
fontSize1 = 14;

Read in a standard MATLAB gray scale demo image.

folder = 'F:\image';
b = imread('CT-Brain-9541.jpg'); %% same image

info

 imfinfo('CT-Brain-9541.jpg')
ans = 

           Filename: 'F:\image\CT-Brain-9541.jpg'
        FileModDate: '01-Apr-2016 01:02:54'
           FileSize: 20248
             Format: 'jpg'
      FormatVersion: ''
              Width: 354
             Height: 396
           BitDepth: 24
          ColorType: 'truecolor'
    FormatSignature: ''
    NumberOfSamples: 3
       CodingMethod: 'Huffman'
      CodingProcess: 'Sequential'
            Comment: {}

size

 b1= size (b);

[rows columns numberOfColorBands] = size(b);
subplot(2,2,1);
imshow(b, []);
title('original CT brain image', 'Fontsize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% % Get means of Second image
meanredPlane1 = mean2(b(:, :, 1));
meangreenPlane1 = mean2(b(:, :, 2));
meanbluePlane1 = mean2(b(:, :, 3));

redPlane1 = b(:, :, 1);
greenPlane1 =b(:, :, 2);
bluePlane1 = b(:, :, 3);

subplot(2, 2, 2); imagesc (b<40);
  colorbar; title('disease');
% colormap('jet');

 subplot(2, 2, 4); imagesc (redPlane1);
 colorbar; colormap('jet');

% Let's get its histograms.
% [pixelCountR1 grayLevelsR1] = imhist(redPlane1);
% subplot(2, 2, 3);
%plot(pixelCountR, 'r');
% stem(grayLevelsR1,pixelCountR1, 'b');
subplot(2, 2, 3); hist(single(b(:)),256);
str1=sprintf('Histogram of CT brain', 'Fontsize', fontSize);
title(str1);
xlabel('Intensity values','Fontsize', fontSize1);
ylabel('Number of pixels', 'Fontsize', fontSize1);
% xlim([0 grayLevelsR1(end)]); % Scale x axis manually