PS is a real scientific research tool, helping to quickly divide and label work

Tip: This paper proposes a fast semantic segmentation and labeling method based on PS to solve the problems of cumbersome labeling and inaccurate edge positions for semantic segmentation tasks, and a series of semantic segmentation dataset construction and conversion methods will be introduced later.


foreword

What is Semantic Segmentation?

Semantic segmentation is a typical computer vision problem that involves taking as input some raw data (e.g., planar images) and converting them into masks with highlighted regions of interest. Full-pixel semantic segmentation, where each pixel in an image is assigned a class ID according to the object of interest it belongs to.
Introduction to the basic concepts of semantic segmentation: (Introduction to semantic segmentation)

What are the common segmentation labeling methods?

Use of the labelme labeling tool: labelme
Put a labelme label picture here. It is not difficult to see that labelme needs to be dotted around the edge of the object to be labeled, and the number of dots is proportional to the fineness of the segmentation!
On the premise that I don’t have any personal grudges, I simply complain about the labelme:
1. Too few dots, the edges are not marked carefully, too many dots, and the brain, hands and neck are uncomfortable
. 2. Can’t dig holes, which is a problem for certain scenes!
3. Can't directly generate the mask map I want!
insert image description here


2. PS realizes fast semantic segmentation and labeling

1. Use environment

Adobe Photoshop CC 2015 (don't ask why you don't use a higher version, but if my computer has a little more memory, I won't use this version!)
Here is the download link: ( download link )

2. How to use

First, set the foreground and background colors to the corresponding colors of your mask image. Generally, the background color is black, and the foreground color is the color of the object you marked.
insert image description here
Then, pay attention to switch to the American keyboard (shift+ctrl).
The marking tools include: magnetic lasso tool, When using it, just walk around the edge, hold down alt to switch to the polygonal lasso tool (used when the boundary is obviously a straight line), this tool is suitable for pictures with inconspicuous boundaries. Quick selection/magic wand tool, suitable for
boundaries For obvious annotations, especially specific object annotations, the right button can be switched to the magic wand tool. This tool is suitable for area division with similar colors. The
shortcut key commonly used in the annotation process is undo: ctrl+alt+Z
insert image description here

insert image description here
After the selection area is created, the target area needs to be filled with a category color, and the background area is black. Shortcut keys: ctrl+del: background color fill, ctrl+shift+i: invert the selection area to obtain the background color, alt+del: foreground color fill, if If there are multiple categories, just change the foreground color. Then
insert image description here
, invert the selection (shortcut key CTRL+SHIFT+I), fill the foreground color (shortcut key ALT+DEL)
insert image description here
and finally, save the picture as a binary PNG image (shortcut key CRTL+ALT +SHIFT+S), pay attention here to modify the color table to mark the color of the mask image for you (the background color is in the front, and the foreground color is in the back). Otherwise, a three-dimensional PNG image will be generated, causing the semantic segmentation model to fail to train!
Select PNG-8 128 dithering in the preset column, select PNG-8 format in the next column, and then select the color table in the next column. Note that the color table here must correspond to the category colors in mmseg one by one, and the background is in the front It is black, and the category color can be customized, preferably (128, 0, 0) red, (0, 128, 0) green, (0, 0, 128) red, (128, 128, 0), according to mmseg/datasets Adjust the color order in /voc.py, and store it in the target folder after processing.
insert image description here
The generated binary image is as follows:
insert image description here
The mask image dimension check function is attached:

def get_Image_dim_len(png_dir: str,jpg_dir:str):
    png = Image.open(png_dir)
    png_w,png_h=png.width,png.height
    #若第十行报错,说明jpg图片没有对应的png图片
    png_dim_len = len(np.array(png).shape)
    assert png_dim_len==2,"提示:存在三维掩码图"
    jpg=Image.open(jpg_dir)
    jpg = ImageOps.exif_transpose(jpg)
    jpg.save(jpg_dir)
    jpg_w,jpg_h=jpg.width,jpg.height
    print(jpg_w,jpg_h,png_w,png_h)
    assert png_w==jpg_w and png_h==jpg_h,print("提示:%s mask图与原图宽高参数不一致"%(png_dir))

Summarize

This article introduces the core method of PS to realize fast semantic segmentation and labeling, for everyone to exchange and discuss!
Past review:
(1) Interpretation of CBAM papers + Pytorch implementation of CBAM-ResNeXt
(2) Interpretation of SENet papers and code examples
(3) Understanding of ShuffleNet-V1 papers and code reproduction
(4) Understanding of ShuffleNet-V2 papers and code reproduction
(5) GhostNet paper understanding and code reproduction
Next issue notice:
VOC semantic segmentation data set construction method based on PS

Guess you like

Origin blog.csdn.net/qq_44840741/article/details/127692071