简体   繁体   English

使用pytorch进行图像分割

[英]Image segmentation using pytorch

I am using pytorch for image segmentation.我正在使用 pytorch 进行图像分割。 I want to calculate the masked area in the segmented picture below.我想计算下面分割图片中的遮罩区域。 My question is it it possible to calculate the masked area?我的问题是可以计算遮蔽区域吗? If so how can i do that.如果是这样,我该怎么做。

enter image description here在此处输入图像描述

used torchvision.使用 torchvision。 I want to know if there is any way to calculate the masked area of the boat in the segmented picture?我想知道有没有办法计算出分割后的图片中船的遮蔽面积?

Let say you have a predicition output of the same shape as the input of shape [height, width] of type torch.long or torch.int where each element is the class index of its corresponding pixel:假设您有一个形状与类型为torch.longtorch.int的形状[height, width]输入相同的预测输出,其中每个元素都是其对应像素的类索引:

seg_output = ...
BOAT_INDEX = ...

boat_area = torch.sum(seg_output == BOAT_INDEX)
boat_area_propotion = boat_area / (height * width)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM