Auto-crop images of animals (image computation)

Hi,

Does any of you have a free way to auto-crop images of animals?

I now lose a lot of time doing so manually.

I think it should be possible with Wolfram Image Computation https://www.wolfram.com/language/core-areas/image/ but I am not sure it’s possible for free.

If you have any tutorials or easy methods, please share.

Kind regards,

Vincent Verheyen

if you’re wasting a lot of time cropping, just don’t crop.

5 Likes

I generally don’t bother cropping unless the subject of the photo is small compared to the photo and would lose detail when shrunk to iNat’s size. Photos come from my camera at 4000×3000.

1 Like

Making us aware of the function ImageTrim of of the Wolfram Language in a new comment: https://reference.wolframcloud.com/language/ref/ImageTrim.html which allows to crop to a region of interest.

Another thought is to try general purpose image editing software such as Photopea / Photoshop / GIMP / Canva / etc…

Finally, on iOS, there is the concept of creating ‘stickers’ from pictures. Which allows to crop in a content-aware manner with minimal user selection of the subject. See https://support.apple.com/guide/iphone/make-stickers-from-your-photos-iph9b4106303/ios This functions quite well, however, it also does not simply crop; instead it removes any background from the selected subject. I am not sure whether or not this is desireable for iNaturalist, or whether or not there are any guidelins on this?

Adding to the general auto-crop requirement, it is crucial to:

  • be able to process in bulk. Otherwise, this will not save time and is of no use. The bulk-aspect could be with or without intermediate human review/adjustments step.

It is nice-to-have to:

  • retain the location and time metadata of the original images in the cropped images. Otherwise, an additional step needs to be executed / automated, to paste back such metadate onto the cropped image.

On the topic of cropping (not specifically auto-cropping), see also https://forum.inaturalist.org/t/incorporate-basic-image-editing-tools-crop-rotate/1223/.

1 Like

Hello,

Lightroom makes it really easy to crop then export photos, and I’m sure other catalogging apps will offer similar features.
I’ve never considered cropping an issue, yet I crop almost every single image. But I also spend quite some time editing them, which makes the cropping time absolutely non-relevant.

Cheers

Francois

2 Likes

Hi @francoislibert, thank you for the feedback. And it comforts me to know that there are other people out there who care about cropping! :)

However, does Lightroom feature a content-aware auto-crop, in that it could auto-detect an animal inside the picture and crop it accordingly, for example with an x amount of extra pixels on either side?

Hi Vincent, welcome to the iNat Forum. I saw you commented on another topic about this one being moved from General to Nature Talk. Topics that don’t pertain specifically to iNaturalist, but rather nature observation or documentation more generally (such as photography, photo editing software outside of iNat, photography equipment) occur in Nature Talk. Asking for tips on autocropping fits Nature Talk as there is no ability within iNaturalist to do this.

If you do have end up having a proposal for a new feature on iNaturalist you can use Feature Requests and fill out the template that pops up.

3 Likes

i crop in gimp. the first time you export something you have to make sure you have the right settings checked on the export dialogue (if you’re not sure exactly what format your metadata is in it doesn’t really hurt to check them all):

it will then remember your settings so you only have to do this once. i also recommend using the rectangular select tool to pick out the region you want to crop to and then going Image>”Fit Canvas to Selection” rather than “Crop to Selection” as changing the canvas means you can shift the image around if you’re unhappy with the composition (cropping deletes outside of your selection in GIMP, changing the canvas keeps it there but leaves it “out of frame”).

it’s pretty fast but not a totally negligible amount of time, i would really like an in-iNaturalist crop option (i know this has been requested before)

EDIT: i crop manually, i missed that you were only interested in content aware cropping

2 Likes

Hi @yongestation, noting your methods, which indeed do not relate to auto-cropping, as you mentioned in your P.S.

Noting also that auto-cropping does not seem to be prohibited behavior, as per the list in https://www.inaturalist.org/pages/machine_generated_content.

I don’t see the value?
Cropping images takes a few seconds and I can decide how much space I want the organism of interest to take up in the photo.

It seems like using a program to automatically crop images for you would be likely to crop too closely, leaving no background at all (at least if what you are thinking of is anything like the one in Google’s image recognition tool). But sometimes background is helpful for ID, to provide context about habitat, or simply because one can often see the subject better when there is a bit of space around it. Or it might not recognize skinny bits like tails or antennae or tendrils belong to the subject and it would crop out relevant bits of the organism.

4 Likes

Hi @spiphany, indeed an extra padding around the auto-crop would be best, which could be part of the auto-cropping tool.

As for the context you mentioned, yes, indeed, where relevant, I usually left 1 picture without cropping, to show more context outside of the organism.

With a huge amount of observations, and let’s say an average of 10 pictures per observation, it really consumed a lot of time for me to manually crop. At least the official/standard iOS ‘Photos’ app is not efficient at all, it involves many clicks + waiting time, as each action involves a transition time, not to mention the very cumbersome shift outside of the to-be-cropped zone.

Hence I indeed stopped cropping 70% (maybe it’s optimistic) of the pictures, a few days ago, unless it becomes for example too much of a Where-Is-Wally-[the bird in the canopy] kind of game for the human identifier without cropping. It makes for less beautified pictures, but the time waste is too significant to not automate the cropping.

Of course I agree there will always be some manual (human) review of the cropping procedure. There could be a parameter (slider) where the user could decide how large the padding should be, and for the user to quicly correct the computer-vision calculated animal of interest, if faulty, and point towards the correct one, in an artifical intelligent manner.

there are lots of ways to do object detection with open source code. for example: https://forum.inaturalist.org/t/uploading-ai-bounded-images/50884/9.

that said, when i look at your observations, i don’t really see a need to crop any of your images.

1 Like

@pisum Other than my observations, where would you find cropping useful then on iNaturalist? Or are you an anti-cropper? :)

Maybe my observations were already cropped?

crop if you’re going to lose necessary details.

iNaturalist resizes (down) and stores images at a maximum of 2048 pixels along the long edge.

suppose you have a 12MP 3:2 image at 4200px x 2800px. if you have a common bird that is easy to identify, and it fills only the top-left quadrant of the image, you can crop if you like, but it’s probably not going to help identifiers identify any better. if you want to crop it just for artistic purposes, that’s fine, but if you lose the context present in the remaining 3/4ths of the image, what’s the point? you might even lose information about what kind of habitat the bird likes, what it eats, how it associates with other birds, etc.

suppose in the same image that there’s an unusual insect that requires looking at wing veination to accurately identify, and it occupies just the bottom-right 1/16th of the image. that is an image where i would consider uploading the original image, plus a cropped version of the image. the original image provides context (the plant that the insect might be eating, a common bird nearby for size reference, etc.), but the crop provides as much detail as possible for identification. however, i would only crop if sufficient detail is present in the image. if the image is very blurry or grainy to begin with, cropping won’t necessarily help.

2 Likes

@pisum I see, thank you. Is there some page with some guidelines on this? I see that the stills which I extract from my video are about 8MP - 3840x2160 - 1.5 to 2.5MB. Would there be any image quality loss when uploading?

So, you are saying, for identifiers, it doesn’t really matter that they have to zoom in on 20 pictures in order to properly look at the organism? I myself can’t tell by experience, whether or not that is comfortable, because I am only/mostly on iNaturalist as an observer.

I equally have thought of the ‘habitat’ hypothesis against cropping earlier, but I find it quite limited in most pictures, what such larger picture could add to properly and positively identify. Further more, with location-accurate observations, the habitat could be quite well understood from the geo data, and from other observations nearby. Nevertheless, while I was still cropping by default, I often kept at least 1 picture for such larger context, often times.

every identifier is different, and each observation is different.

given the choice of just one version of a photo, i personally would almost always prefer the whole original image, unless it’s a situation where necessary detail would be lost, as i noted above. the way i look at it, i can always zoom in as a viewer, but i can’t see the stuff that you’ve cropped away. this is especially true with plants, where people often fail to capture necessary parts of plants (ex. take a photo of the flower but crop out the leaves).

folks who deal with animals may be more likely to prefer cropping for identification purposes, since it’s usually easier to make sure you capture the entire animal in your crop, but my contention is still that the benefit vs cost usually not worth it for either the observer or viewers of the observations. (my personal experience is that i get more questions about about the plant that an animal is eating or using as a host than requests for closer views of animals. if i crop too closely, i lose the context to be able to answer the questions about host plants.)

if in doubt, you can always include original + crop, but again, i just don’t think it’s necessary in the vast majority of cases.

OK, thank you for those additions @pisum. Reading up on your point, I see that it is claimed that “iNaturalist scales down anything larger than 2048×2048”, as per the 2023 post https://forum.inaturalist.org/t/clarification-on-photo-resizing-vs-resolution/47478 , hence I might still need to crop my movie stills a bit when it comes down to for example a butterfly far away.

And considering the dimensions above, I should just be aware that any picture which I don’t crop will result in image loss during upload.

Of course, if we take the argument against cropping further, we could also say we need to remove the limit of 20 pictures, or even allow the upload of video instead of merely pictures. I am reasoning ad absurdum now perhaps, because again, as you mentioned it comes down to a cost benefit ratio, in this case for the storage capacity and costs of iNaturalist.

Considering I am always starting from movies, the question then perhaps for me is also how to automate the extraction of sharp stills from a movie, and if even more artifically intelligent, only those stills, with a maximum of 20 stills, that show the animal of interest. Now, all or much is possible in the world of IT, but the question is how to make a user-friendly tool, or where to find one. In any case, a lot of time is still lost on manual editing, as for now. Even the aiming of my camera/lens (which is of poor bad quality again, when the object is far) is currently another manual process and thus often missing the moving target.

here’s an example of an observation where you included 9 images: https://www.inaturalist.org/observations/317790421. in my opinion, you really only needed the first image. since this is a gall, and it’s often important to know the host plant to identify galls properly, i would have also included an image that shows the entire leaf (to give a reasonable chance of identifying the plant), but none of your 9 images show the whole leaf. so if you spent a bunch of time extracting and cropping these 9 photos, i would say that you could have reduced your work by almost 90% by just including 1 image for this observation.

2 Likes

Regaring the leaf gal: I wasn’t aware of that, thank you. In fact I did not crop in this case, as in my whole movie there was no clearer wider image of the leaf on this side nor the other. But I will take this new knowledge into account, I see your point. If I had known this knowledge, I would have made the footage differently. Since this is a leaf gal, it could thus be caused by an insect, or a bacteria or fungi. I will update the observation accordingly, textually.

Noted the concern for the loss of context.

However, I still think, following our conversations above, that cropping is important in many cases. As we discussed, to prevent loss of quality during the upload resizing which would otherwise occur. As, for example, with my image quality, every time I do not crop a picture, means that the uploaded image will lose image quality once uploaded, which can be detrimental for the identifiers. Think of, for example pictures of a bird against nothing but a blue sky. In such cases, an auto-cropping tool would be very useful and a time-saver. As long as a human keeps the oversight that not too much context is cropped away, or at least 1 picture remains with the context that would be cropped away in the other pictures.