image labelling for background

I want to label images in order to use it in semantic segmentation
However, i want to label only specific area,
so if i only mark specific areas in whole image dataset
the areas which are not mark are automatically assumed as background?
Or do i have to mark it manually mark it as background as well?

Answers (2)

Image Analyst
Image Analyst on 8 Apr 2019
It depends on what you want to do. If you only process the things you have labeled, then you don't need to worry about the background being labeled since even if it were, you'd not process it. If you want to process it, then you need to label it.

5 Comments

what do you mean by process, i only want to segment 1 object in the image, for that do i need to label background for all images ?
Sir, did you volve this problem or yet?
i need the solution of it
Same problem I also want to segment one object, have you got the solution?
Please help
You do not need to label the background (i.e. with bwconncomp or bwlabel). All you need to do is to segment out the foreground and process it (like find the area, brightness or whatever you want to do.) I go over all this in my Image Segmentation Tutorial
any solution to this? is there an automatic way to label the undefined pixels as background? I want to use a cnn to do semantic segmentation of a specific object. The examples MATLAB offers come with datasets that two classes and no undefined pixels.

Sign in to comment.

So I solved this by only labeling the desired areas in my images with the class cat and the background was left without a label.
pxDir = fullfile('...'); % insert your directory
imds = imageDatastore('...'); % insert your directory
classNames = ["cat"];
pixelLabelID = [1];
pxds = pixelLabelDatastore(pxDir,classNames,pixelLabelID);
C = readimage(pxds,1);
undefinedPixels = isundefined(C);
If you look at C, the entries are either '<undefined>' or 'cat'. Also if you look at undefinedPixels you'll see how many of the pixels have this label and you can even plot it. So I replaced these two lines
classNames = ["cat","background"];
pixelLabelID = [1,0];
and now C shows either 'background' or 'cat'. If you run the
undefinedPixels = isundefined(C);
again, you'll find sum(sum(undefinedPixels)) is zero.

Products

Release

R2018b

Asked:

on 8 Apr 2019

Answered:

on 22 Apr 2020

Community Treasure Hunt

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

Start Hunting!