Medical Image Segmentation Using SegNet

4 views (last 30 days)
soheib hadj moussa
soheib hadj moussa on 14 Apr 2020
Answered: Ryan Comeau on 9 May 2020
Hi,
I labeled gray scale images using Pixel Label in Image Labeler app (MATLAB 2019b). I am using semantic segmentation (https://www.mathworks.com/matlabcentral/fileexchange/66448-medical-image-segmentation-using-segnet) to classify different objects in the images. When I ran this part of the code (I changed the third element in the imageSize to 1 because I am using the gray scale images):
i find this error
Error using segnetLayers>iCheckImageSizeHasThreeElementsForVGG (line 454)
imageSize must have three elements and the third element must be 3 when creating SegNet based off of VGG-16 or
VGG-19.
Error in segnetLayers (line 170)
iCheckImageSizeHasThreeElementsForVGG(args.imageSize);
Error in medImgSegExample3 (line 75)
lgraph = segnetLayers(imageSize,numClasses,'vgg16');

Answers (1)

Ryan Comeau
Ryan Comeau on 9 May 2020
Hello, I have encountered this problem as well. It's sort of hilarious because it's a simple problem and I banged my head against the table as well for like 10 hours. When you are doing transfer learning(the technique of using pre trained weights) your images need to be the same size as the ones which the network was trained on, which includes the color channels. This leaves you with two solutions:
  1. train your own detector, just take their architecture
  2. Turn your images from greyscale into rgb by using the following bit of code(i used this for SSD object detection, but based on your error it seems to be the same issue). The rgb2gray is here:https://www.mathworks.com/matlabcentral/answers/377407-how-to-convert-grayscale-to-rgb
map = hsv(256); % Or whatever colormap you want.
rgbImage = ind2rgb(im, map); % im is a grayscale or indexed image.
You will need to play around with the value in hsv and tune it to your needs.
Hope this helps
RC

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!