File Exchange

image thumbnail

Medical Image Segmentation Using SegNet

version 1.0.0.1 (1.75 MB) by Kei Otsuka
How to create, train and evaluate SegNet for medical image segmentation

53 Downloads

Updated 06 Dec 2018

View License

Deep Learning is powerful approach to segment complex medical image.
This demo shows how to prepare pixel label data for training, and how to create, train and evaluate VGG-16 based
SegNet to segment blood smear image into 3 classes – blood parasites, blood cells and background.
医用画像処理において、Deep Learningは非常に強力なアプローチの一つです。
本デモでは、ネットワーク学習のためのラベル画像の準備、SegNetの作成と学習、そして評価までの一連の流れをご紹介します。使用する画像は血液塗抹標本画像で、この画像をSegNetを用いて3クラス(赤血球、病原虫、背景)に分割します。

[Keyward] 画像処理・セグメンテーション・ディープラーニング・DeepLearning・デモ・IPCVデモ
・ニューラルネットワーク・医用画像

Cite As

Kei Otsuka (2019). Medical Image Segmentation Using SegNet (https://www.mathworks.com/matlabcentral/fileexchange/66448-medical-image-segmentation-using-segnet), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Kei Otsuka

How did you run the script?
To run a script, including all local functions, please use "Run" button, or use "Run Section" button to run individual sections in a script.

Sir i am using R2018b. Sir As i am running the code as it is. it does not find the Code for "bloodSmearColorMap " function and give error "Undefined function or variable 'bloodSmearColorMap'. ".
See the following code and error
>> imageLabeler
>> classes = [
"Background"
"BloocCells"
"BloodParasites"
];

pixelLabelID = cell(3,1);
pixelLabelID{1,1} = [2;0];
pixelLabelID{2,1} = 1;
pixelLabelID{3,1} = 3;
>> labelDir = fullfile(imgDir,'PixelLabelData');
>> pxds = pixelLabelDatastore(labelDir,classes,pixelLabelID);
>> C = readimage(pxds, 15);
>> cmap = bloodSmearColorMap;
Undefined function or variable 'bloodSmearColorMap'.

>>

Sir i have used R2018b. Sir As i am running the code as it is. it does not find the Code for "bloodSmearColorMap " function and give error "Undefined function or variable 'bloodSmearColorMap'. ".

Kei Otsuka

Hi Muhammad,

You do not need to create another file for bloodSmearColorMap function. MATLAB should find this function in script if you use R2016b or later.
Which MATLAB version are you using?

Thanks for your nice anticipation sir,
Now i copy the code of "bloodSmearColorMap" function and paste it another file named as bloodSmearColorMap.m. this line of code "cmap = bloodSmearColorMap;" works properly,
But Now next code line give an error
>> C = readimage(pxds, 15);
>> cmap = bloodSmearColorMap;
>> B = labeloverlay(I,C,'ColorMap',cmap);
Error using labeloverlay>parseInputs (line 152)
The value of 'Colormap' is invalid. Expected Colormap to be an array with number of columns equal to 3.

Error in labeloverlay (line 87)
parsedInputs = parseInputs(varargin{:});

>>
Please guide me, how can i fix it . i am very thankful to you sir......... waiting for your kind answer please....

Kei Otsuka

Hi Muhammad,

Thank you for the note.
bloodSmearColorMap is written in medImgSegExample3.m as a part pf supporting functions.
Please see line 277 of medImgSegExample3.m

Hi Sir, How are you, hope you will be fine and going well,
As i run this code on my system , following error come:
>> cmap = bloodSmearColorMap;
Undefined function or variable 'bloodSmearColorMap'.
Please Guide me, how can i fix it, As i search 'bloodSmearColorMap' every where in the folder and on google, But not found...

Kei Otsuka

ご指摘ありがとうございます。R2018bでセッションファイルの仕様が若干変更になっておりまして、
エラーになるようです。
対処方法ですが、
reconstLabelSession.mファイルの 7行目 ~ 17行目を以下の内容に置き換えて頂ければと思います。

if verLessThan('matlab','9.5')
load('imageLabelingSession.mat')
imageLabelingSession.FileName = fullfile(pwd, 'imageLabelingSession.mat');
sz = size(imageLabelingSession.ImageFilenames);
for i = 1:sz(1)
fname = imageLabelingSession.ImageFilenames{i};
[pathstr,name,ext] = fileparts(fname);
fname = fullfile(pwd, [name ext]);
imageLabelingSession.ImageFilenames{i} = fname;
end

save('imageLabelingSession.mat', 'imageLabelingSession')
end

お世話になっております。medImgSegExample3.mを実行したところ
次のようなエラーメッセージが表示されました。
====以下、引用======
Session の読み取り専用プロパティ 'ImageFilenames' を設定できません。

エラー: reconstLabelSession (line 14)
imageLabelingSession.ImageFilenames{i} = fname;

エラー: medImgSegExample3 (line 46)
reconstLabelSession
===引用終わり====

お手数ですが、解決方法がありましたら教えていただけると幸いです。

自分のPCの環境は
Windows 10
MATLAB R2018b
です。

よろしくお願いします。

Updates

1.0.0.1

updated to make it compatible with R2018b

MATLAB Release Compatibility
Created with R2017b
Compatible with R2017b to R2018b
Platform Compatibility
Windows macOS Linux

medImgSegNet

medImgSegNet