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:
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 !
2 | No.2 Revision |
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:
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 !
3 | No.3 Revision |
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:
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 !
4 | No.4 Revision |
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:
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 !