Consider I have an image
with shape (240, 320, 4) and after applying the slic method function to superpixels.
I want to resize those superpixels in (segments 2)
in order to have the same shape.
How to upsample these segments to all have super pixel size, it's ok to insert to zeros in the edges?
num_segments = 400
img = img_as_float(imread('1.png'))
#if len(img.shape) > 2 and img.shape[-1] == 4:
# img = img[:, :, :3]
segments = slic(img, compactness=30, n_segments=num_segments)
superpixels_ids = np.unique(segments)
for id in superpixels_ids:
pixels_per_sp = img[segments == id]
print(pixels_per_sp.shape)
plt.figure()
plt.imshow(mark_boundaries(img, segments))
plt.show()
the pixels_per_sp.shape have different sizes when they are plotted
(199, 3)
(203, 3)
(195, 3)
(232, 3)
(211, 3)
(211, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(202, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(210, 3)
(180, 3)
(198, 3)
(196, 3)
I would like to upscale the superpixels all to have exactly one size like if I can ad zeros in the edges of each superpixel
Another question: is there a way that I can keep the image as RGBA and apply slic still? thnaks

