question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhancement: attention crop strategy improvements

See original GitHub issue

These are via @jcupitt, thanks John.

Rank regions by average rather than maximum value

sharp uses max on the sum image. This is very sensitive to noise, to the exact alignment of the masks, and takes no account of how “much” of something there is. A single pixel of skin colour is as significant as a whole face.

We could gaussblur before max, but the simplest thing is probably just to use avg rather than max.

No need to separate A and B channels when detecting skin tones

sharp does

a = lab[1]
b = lab[2]
skin = (a >= 3) & (a <= 22) & (b >= 4) & (b <= 31)

It would probably be slightly quicker to get ab as a two-band image, then do the tests against a two-element array, then AND the two bands together, something like:

ab = lab[1:2]
skin = (ab >= [3, 4] & ab <= [22, 31]).bandand()

Investigate using L channel in skin tone detection

When sharp tests for skin colour, it just tests AB, it doesn’t test lightness. I found a few images where very deep shadows were mistakenly tagged as skin, throwing off the crop.

(The L channel values were discarded when the current thresholds were “trained”. Let’s add them back into the mix and see what it comes up with.)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jcupittcommented, Mar 16, 2017

I had another thought – the cropper works at the moment by discarding boring areas, which is quick, but it means it won’t centre on interesting areas.

Instead, how about calculating a score image, as now, but doing it for the whole frame. Then shrink, blur, search for the peak, and centre the crop box on that. There’s some sample code here:

https://github.com/jcupitt/libvips/blob/master/libvips/conversion/smartcrop.c#L162

And a little discussion here:

https://github.com/jcupitt/libvips/issues/619

It’s a bit slower, but not catastrophically.

[update jcupitt/libvips#619 has been improved a bit more, and now has a nip2 workspace for experimenting with the settings, plus some useful test images]

1reaction
lovellcommented, May 6, 2017

Commit 36078f9 on the ridge branch makes an internal switch to the smartcrop feature of libvips. The existing public API remains the same. This will be in v0.18.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Endophyte-Mediated Stress Tolerance in Plants - PubMed
Endophyte-Mediated Stress Tolerance in Plants: A Sustainable Strategy to Enhance Resilience and Assist Crop Improvement.
Read more >
Pioneering an inclusive approach to priority setting in crop ...
The processes for breeding programs to set priorities are variable. The most developed approaches focus on ex-ante evaluations and economic ...
Read more >
Review: The Next Steps in Crop Improvement - OSTI.gov
These and other crop improvement strategies are successful when applied ... Special attention should be paid to those plants where an increase in....
Read more >
In pursuit of a better world: crop improvement and the CGIAR
The One CGIAR strategy brings to the forefront the attention required to ensure gender equality, opportunities for youth, and inclusion, and to promote...
Read more >
Multi-omics approaches for strategic improvement of stress ...
However, little or no research attention is given toward neglected and underutilized crop species (NUCS) which hold the potential to ensure food and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found