I have a PDF file that contains 3 pages of microphotographs that are subdivided into subimages of several individual micrographs. For the first two pages the individual photomicrographs are arranged in a 3x2 array (labeled A-F) whereas on the last page, the last element of what would be an another 3x2 array is missing so that only micrographs labeled A-E appear.
I seek to save these micrographs (array elements) each as a single image file that can be subsequently associated with data from the image captions. When imported the original files contain a single image each so I seek to subdivide each page into its natural component micrographs minimizing retaining maximum resolution with minimal distortion of the proportional heights and widths.
Here is a down sampled version of the 6 micrographs on the first page:
Using the following, I nearly succeed in partitioning the single image containing 6 micrographs arranged in 3 rows of 2 micrographs each so that each sub image can be saved as an individual file and associated with the appropriate figure captions, eventually all bundled within a Dataset.
subimages = Flatten[ImagePartition[image6, {210/3}]]
However, note that the two micrographs labeled "C" and "D" actually contain a small portion of the pixels in the previous two micrographs. I've attempted to alter the value passed for the individual image widths, but increasing or decreasing this value typically as well as playing with Ceiling/Floor functions and padding results either in an additional number of unwanted partitions, or too few partitions in which some of the individual micrographs are lost. It seems this arises from the individual micrographs not being all the same image dimension. Similar results emerge when using the larger original files, although the values for widths are necessarily larger.
How can one partition the original image so that the desired effect is achieved even when the sub images are not uniformly sized?
Ideally, an automatic solution is sought that does not require manual tweaking in such situations. I have tried to segment the original image into a list of components following the suggestions for questions 35249 and 109154, but using either MorphologicalComponents[] or ImageForestingComponents[] fail to get all parts of all desired sub images. Usually 4 or 5 of 6 micrographs, can be obtained but unfortunately both functions break some individual micrographs into many undesirable smaller components. These not easily joined to recreate the missing "whole" components sought, because the components of these missing elements typically appear in arbitrary order and there may be several hundreds or thousands of them. Thus, making them difficult to identify and recompose into a single sub image (micrograph).
Croping and then arranging cropped parts into a list might work, but I can't figure out how to tell ImageCrop how to determine the border dimensions of the desired sub images before the command is executed without considerable trial and error that needs to be avoided to achieve a fully automated process.