简体   繁体   中英

How to find area in pixels output

I need to output the area in pixels for the binary_mole.

mole_1 = mpimg.imread('mole_1.png')
gray_mole = rgb2grey(mole_1)
threshold = skimage.filters.threshold_otsu(gray_mole)
binary_mole = (gray_mole < threshold)

My attempt to find the area in pixels is below

trys = np.sum(binary_mole == 255)
print('number of white pixels = ' , trys)

The binary_mole looks like 在此处输入图像描述

How do I fix this or go about it?

There is a built in function called regionprops, that has numerous measurements.

import skimage.measure as meas
binary_label = meas.label(binary_mole)
measurements = meas.regionpros(binary_label)

area = measurements[0]['area']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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