Skip to content

cv2.ximgproc.segmentation.createGraphSegmentation seems to handle wrongly float32 images (NumPy) #3544

Open
@vadimkantorov

Description

From the code it seems that the images get cast to float32 ([0.0, 1.0] range, right?) anyway:

img.convertTo(img_converted, CV_32F);
, so why is not working if I'm passing directly a float32 image?

Is it supporting only uint8 inputs?

What is the effect of passing float32 and int32 images?

Thanks!

import numpy as np
import cv2

gs = cv2.ximgproc.segmentation.createGraphSegmentation(0.8, 150, 100)

np.random.seed(0)
img_float32 = np.random.rand(200, 300, 3)
img_float32_255 = img_float32 * 255
img_uint8 = (img_float32 * 255).astype('uint8')
img_int32 = (img_float32 * 255).astype('int32')

print(gs.processImage(img_uint8).max()) # 97
print(gs.processImage(img_float32).max()) # 0
print(gs.processImage(img_float32_255).max()) # 104
print(gs.processImage(img_int32).max()) # 97

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions