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);

No comments:

Post a Comment