Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

your problem is basically known as "segmentation", and maybe you should look for higher level methods to achieve this.

as an example, opencv_contrib has a newly added hfs module, that does this easily:

image description

import cv2
import numpy as np

img = cv2.imread(image_path)

# create engine
engine = cv2.hfs.HfsSegment_create(img.shape[0], img.shape[1])
engine.setSlicSpixelSize(300);
# perform segmentation
# now "res" is a matrix of indices
# change the second parameter to "True" to get a rgb image for "res"
res = engine.performSegmentCpu(img, False)

i choose the color representation here, and ofc. it would look nicer w/o the harris dots you added.

there are also a couple more algorithm to try in ximgproc, and we have an fcn pretrained cnn for this, too !

your problem is basically known as "segmentation", and maybe you should look for higher level methods to achieve this.

as an example, opencv_contrib has a newly added hfs module, that does this easily:

image descriptionimage description

import cv2
import numpy as np

img = cv2.imread(image_path)

# create engine
engine = cv2.hfs.HfsSegment_create(img.shape[0], img.shape[1])
engine.setSlicSpixelSize(300);
engine.setSlicSpixelSize(200);
# perform segmentation
# now "res" is a matrix of indices
# change the second parameter to "True" to get a rgb image for "res"
res = engine.performSegmentCpu(img, False)

i choose the color representation here, and ofc. it would look nicer w/o the harris dots you added.

there are also a couple more algorithm to try in ximgproc, and we have an fcn pretrained cnn for this, too !

your problem is basically known as "segmentation", and maybe you should look for higher level methods to achieve this.

as an example, opencv_contrib has a newly added hfs module, that does this easily:

image descriptionimage description

import cv2
import numpy as np

img = cv2.imread(image_path)

# create engine
engine = cv2.hfs.HfsSegment_create(img.shape[0], img.shape[1])
engine.setSlicSpixelSize(200);
# perform segmentation
# now "res" is a matrix of indices
# change the second parameter to "True" to get a rgb image for "res"
res = engine.performSegmentCpu(img, False)

i choose the color representation here, and ofc. it would look nicer w/o the harris dots you added.

there are also a couple more algorithm to try in ximgproc, and we have an fcn pretrained cnn for this, too !

your problem is basically known as "segmentation", and maybe you should look for higher level methods to achieve this.

as an example, opencv_contrib has a newly added hfs module, that does this easily:

image description

import cv2
import numpy as np

img = cv2.imread(image_path)

# create engine
engine = cv2.hfs.HfsSegment_create(img.shape[0], img.shape[1])
engine.setSlicSpixelSize(200);
# perform segmentation
# now "res" is a matrix of indices
# change the second parameter to "True" to get a rgb image for "res"
res = engine.performSegmentCpu(img, False)

i choose the color representation here, and ofc. it would look nicer w/o the harris dots you added.

there are also a couple more algorithm algorithms to try in ximgproc, and we have an fcn pretrained cnn for this, too !