Refactor and improve image resizing
See original GitHub issueIs your feature request related to a problem? Please describe.
The function plantcv.resize
could be improved in a few ways. It currently allows for resizing the x and y dimensions using scaling factors, but resizing to an exact size may be desirable also. We also use a single, fixed interpolation method that may not yield optimal results in all cases.
Describe the solution you’d like
I propose a few modifications to plantcv.resize
and a new function.
- Move
plantcv.resize
to thetransform
subpackage:plantcv.transform.resize
. This is both because it is a transformation of the input image and it’s consistent withscikit-image
. - Refactor
plantcv.transform.resize
to resize images to an exact size. - In
plantcv.transform.resize
, if the new size is smaller than the input size, use the OpenCV interpolation methodcv2.INTER_AREA
. If the new size is larger than the input size, use the interpolation methodcv2.INTER_CUBIC
. (These are the generally recommended options, but we could point a user to the OpenCV function if they want more control than what we provide). - Make a new function called something like
plantcv.transform.resize_factor
that combines the new features proposed forplantcv.transform.resize
but uses the current feature of scaling the sizes by factors rather than exact sizes. - To avoid redundancy, it may be useful to have a helper function set the interpolation method.
Describe alternatives you’ve considered These functions could be wrapped into one like the OpenCV function, but I think it’s simpler to have two smaller functions rather than twice the inputs to one.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Refactor: Scaling Images - LearnHowToProgram.com
In this lesson we will walk through retrieving higher-quality files from the Yelp API, and resizing them appropriately using Picasso in order to...
Read more >refactor (bbb-web): Improve large images resizing and ...
Resize the images larger than allowed based on the new configs. maxImageWidth; maxImageHeight. It also removes the previous config. maxImageSize ❌
Read more >Free Image Resizer: Resize Photos Online | Adobe Express
Resize your photos easily with the Adobe Express free image resizer. Simply upload your pictures, change the photo size, and download your new...
Read more >BIRME - Bulk Image Resizing Made Easy 2.0 (Online & Free)
BIRME is a flexible and easy to use bulk image resizer. It can resize multiple images to any specific dimension and crop images...
Read more >Resizing TIFF images using run(scale...) does not work!
Hi, I would like to enhance the resolution (or size) of several ... Resizing TIFF images using run(scale. ... REFactor = 10; run("Scale....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nfahlgren probably not necessary. i can’t think of any applications for shear or skew over warp. it can always be revisited.
Hi @DannieSheng, it did come to my mind while I was reviewing your PR! I realized that the resize function you proposed there does not use interpolation though, it either crops or pads as you said. Maybe now that I think about it, these could potentially be one function?