1
$\begingroup$

I have a sample of 50,000 images, some of which are shown below:

enter image description here $\qquad$ enter image description here $\qquad$ enter image description here $\qquad$ enter image description here $\qquad$ enter image description here

Associated to these images are labels for the digit with the largest pixel size. My goal is to build a machine learning model to predict the largest digit in an image by pixel size.

To that end, I used transfer learning on the resnext model, but only found an accuracy of 60%.

Given that this implementation uses transfer learning to train a model to predict MNIST digits, I would now like to crop each training image to retain only the largest digit and then train the model using the linked implementation.

So, my question is, how I do crop the training images to retain only the digit in each image with the largest size.

$\endgroup$
  • $\begingroup$ you mean most number of pixels? CNNs would need labelled data. Do you have data with each image labelled with the boxes around the largest digit? $\endgroup$ – MiloMinderbinder Mar 17 '18 at 17:18
  • $\begingroup$ I don't actually. I have attached images above. I need to draw bounding boxes and crop to retain only the digit with the most number of pixels, so that I can transfer learning using rxtnet to train the network. $\endgroup$ – nightmarish Mar 17 '18 at 18:29
  • $\begingroup$ are all the digits necessarily disconnected in the images? for example: in the first image was there necessarily no trail of continuous black pixels running from one digit to the next? $\endgroup$ – MiloMinderbinder Mar 18 '18 at 0:25
  • $\begingroup$ Cross-posted: datascience.stackexchange.com/q/29180/8560, stats.stackexchange.com/q/335107/2921, cs.stackexchange.com/q/89470/755. Please do not post the same question on multiple sites. Each community should have an honest shot at answering without anybody's time being wasted. $\endgroup$ – D.W. Mar 18 '18 at 19:49
1
$\begingroup$

You need to manually or automatically draw bounding boxes around each digit. Then compute the area for each box and take the largest.

Given they are non-overlapping black digits on a white background, template matching would work.

| improve this answer | |
$\endgroup$
1
$\begingroup$

Find connected components of black pixels, then for each connected component, find its bounding box, and keep the one with the largest bounding box.

(If you run into issues with noise, preprocessing with morphological operators might help. But only try that if the simple approach above doesn't work.)

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.