GithubHelp home page GithubHelp logo

avaneev / avir Goto Github PK

View Code? Open in Web Editor NEW
408.0 23.0 41.0 16.86 MB

High-quality pro HDR image resizing / scaling C++ library, including a very fast, precise, SIMD Lanczos resizer (header-only C++)

License: MIT License

C++ 100.00%
image-resizer image-upsizing image-scaling resizer-image resize-images image-resolution image-processing image-manipulation lanczos bitmap

avir's People

Contributors

avaneev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avir's Issues

optimize on ARM (A53 A73),can realize?

first of all, your code is very excellent, i want to use your code , let it run on ARM CPU, for example, A53, but it is very SLOW!, so ,can you optimize this code on ARM CPU? Best My Regards!

Multithreading HowTo

Thank you for sharing this great resizing library! Results look so good!
Now I would like to get it a little faster using multithreading, but I don't know how. In your documentation I found class CImageResizerThreadPool... is this the right class for multithreading? Unfortunately I have no idea how to use it. Could you please share a small example, how to realize multithreaded resizing with your library? Thanks in advance for your help!

16 bit capable image format support

It's difficult to talk about "high quality images" with quite destructive image formats such as jpg and png.
I suggest adding DNG support.

Trying to understand.

Hi I'm trying to understand how the algorithm works. I have some questions...

  1. When are 18 taps used: for the initial 2x upscale? Or for the final filter? Or both?
  2. What about the correction filter? What does it do/how many taps?
  3. How much/why does each filter deviate from a pure sinc?... I'm guessing some/all of them are shortened, to remove ringing artefacts?
  4. How can AVIR use 18 taps when lanczos is best with 2 or 3, and gets much worse ringing with 6?
  5. When is low pass filtering done? Is it a part of the 2x upscale? Or during the subsequent downscale? Why?
  6. Also what is the "Peaked Cosine" window? I can't find any information about it. Is it similar to blackman?

Image resizer source code

Hello. The repo contains binary files for an image resizer tool. Is the source code for it available?

Example

Hi, Can you please provide an example of how to use this code? Maybe you can use "imresize.exe" as a test case.

AVX doesn't compile

Hello again, Aleksey :)

I tried to compile with the AVX optimized version of float8 data type, but failed.
MinGW/GCC throws the error:

error: inlining failed in call to always_inline '__m256 _mm256_set1_ps(float)': target specific option mismatch                            1310 | _mm256_set1_ps (float __A)
                                                                | ^~~~~~~~~~~~~~                                                                                                                                                                                          
avir_float8_avx.h:50:26: note: called from here
50 |   : value( _mm256_set1_ps( s ))

SSE compiles good.
For AVX, I've tried all posible compiler options, but failed.
Do you know how to fix it?

Can you provide an example code?

It doesn't seem to work when I go to scale the image while reading in the file?
How can I read a local image and save it locally after scaling?
Is an InBuf a file stream, and is an OutBuf a stream containing the entire image file header?
I can't seem to write it this way

#include <iostream>
#include <vector>
#include <fstream>
#include "avir.h"
int main() {

	avir::CImageResizer<> ImageResizer(8);
	uint8_t* file_source = new uint8_t[1920 * 1080 * 3];
	uint8_t* out_source = new uint8_t[1920 * 1080 * 3];
	memset(file_source, 0, 1920 * 1080 * 3);
	memset(out_source, 0, 1920 * 1080 * 3);
	std::ifstream file(R"(D:\Wallpaper\001.jpg)", std::ios::in | std::ios::binary);
	std::uint64_t file_size = 0;
	if (file.is_open())
	{
		file.seekg(std::ios::beg, std::ios::end);
		file_size = file.tellg();
		file.seekg(std::ios::cur, std::ios::beg);
		file.read((char*)file_source, file_size);
		file.close();
	}
	ImageResizer.resizeImage<uint8_t, uint8_t>(file_source,1920,1080,0, out_source,480,270,3,0);
	delete[] file_source;
	std::ofstream outFile(R"(.\1.jpg)", std::ios::out | std::ios::binary);
	if (outFile.is_open())
	{
		outFile.write((char*)out_source, 1920 * 1080 * 3);
		outFile.close();
	}
	delete[] out_source;
	return 0;
}

affine transform

Thanks for your work. Would you add rotation function in the toolkit ? such as affinetransform.

is there a detailed description of the algorithm?

This looks like a great method. is there any document that define the method clearly? or as it implies that the method implements a 18-tap windowed sinc interpolation?

would appreicate if there are graphs/illustrations showing the detailed method.

Few questions about the avir algorithm

First of all, thank you so much for giving us this incredible library. I can't believe it's free and open-source considering it's top-notch quality. Output results look amazing, speed is mind-blowing and the interface is as simple as it can get. Again can't thank you enough for this.

I'm creating an Image Processor for android. Tho the library itself is amazing, I would like to implement my own version of the algorithm to be used in my application. Mainly for the following reasons.

  1. I won't be using most of the extra features offered. I just need to downsize a 8 bit 4 channel image. So hopefully I will be able to cut down the size of the library.
  2. As this is a mobile application, I would like to squeeze out the every bit of performance I can. Implementing my own version will allow me to do optimizations unique to my app environment.
  3. I already have a resizing engine. So I would like this algorithm to be seamlessly integrated into it.

So my questions are,

  1. Do you have any specification at the moment, that I can use to implement it?
  2. Do you think I'll be able to cut off the size by a considerable amount by removing unused features such as (16,24 bit / sRGB featues)
  3. Do I have your permission to implement it into my application? You of course will be credited properly both in docs and the application itself.

PNG-48 (16bit) not working

PNG-48 produce different types of artifacts and will transform an actual photograph into close-to random pixels on canvas. Here attached a resize from 720p to 1080p. Interesting error / truncation. Actual photographs produce bizarre anisotropic noise among other artifacts.
avirtest01-result

avirtest01

Example for using with the Qt library - QImage

Thank for sharing the code.
I’m using the Qt Library and QImage class. I would try to see if ImageResizer.resizeImage is better than the QImage:scaled https://doc.qt.io/qt-5/qimage.html#scaled.
I have no idea on how image format and buffers works.
I wonder if it is possible to use the library with the QImage format and if there are examples for

  • using an existing QImage,
  • creating a buffer and resizing with the ImageResizer.resizeImage
  • converting the result back to QImage.

Speed is not an issue.

sRGB <-> linear, room for performance increase?

It seems the conversion sRGB <-> linear takes a large portion of the time spent.

On my i7 7700 (using msvc, full opt, SSE2), resizing our 30MPx sRGB test photo to about 1/12th of its size takes 650ms on average, applying gamma correction. Without gamma correction, it takes 200ms. Approximating the gamma correction with sqrt(2) takes 220ms (but isn't correct of course).

Do you think the performance of this part of your amazing algorithm could be improved?

Blend2D support

Hello Aleksey,

I have a question regarding how to use your scaling algorithm with Blend2D library: https://github.com/blend2d/blend2d

The Blend2D API provides a way to use custom-defined windowing functions to use for scaling like Lanczos, Blackman and many more.
Could you please guide me how to involve your library properly to provide a windowing function that does scaling using your algorithm?

Thanks,
Arlen.

add --algparams=ultra

Sir, thank you for such a great API.
I was wondering how to add --algparams=ultra to the code, I was able to add to the command line only.

Thank you.

Progress callback?

Is there a way to set a "progress callback function" either before or when invoking CImageResizer::resizeImage()?

I would like to show a progress control in my program while AVIR is resizing a large image. Went looking for a callback in AVIR that would indicate progress while resizing, can't see anything.

Is there a progress reporting method available?

Thanks!

DstScanlineSize?

First of all thanks for this amazing project!

I am doing my first tests with it, and I was wondering why the resizeImage method has a SrcScanlineSize arguments, but not a DstScanlineSize?

Best regards,
Peter

Performance

Not really an issue, but it would be great to have any performance numbers listed in the description/readme. I just tried to use it for real-time processing and, well, it's not fast :)

Ram limit of the win32 exe reach for very big image

While testing the limit of this app (exe, not the C++ code), I noticed that : for one (and not for an other) of my big size png image at 14400x20656 (119MB vs 97,8MB), if I try to resize with scale 4 (=>3600x5164) the exe crash without error reported. After some reseach on this issue, I tried to "patch" the exe with 4GB Patch (https://ntcore.com/?page_id=371) and it no longer crashes.
I don't know if this is normal, but i report it just in case

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.