I am trying to isolate subimages in a large (6000px wide) jpg file. I managed to customize scikit-image segmentation/labeling example to achieve what I want, but had to resize my image so I don't get MemoryError. Is there a way to get the labeled regions' relative position and use them to crop the original? Here's what the importing and cropping/saving bits of my code look like right now:
image = io.imread("Path\to\image.jpg")
image_small = io.imread("Path\to\image_small.jpg")
image_bw = image_small[:, :, 1]
def cropper(source):
count = 1
for region in regionprops(source):
# take regions with large enough areas
if 100000 > region.area >= 1100:
minr, minc, maxr, maxc = region.bbox
# save large enough regions to files
image_name = "image" + str(count)
io.imsave(f"{image_name}.jpg", image_small[minr:maxr, minc:maxc])
count += 1
So ideally I would be able to crop 'image' and not 'image_small'.
Any help will be greatly appreciated!