What's the fastest method for accessing to pixel color?
Posted: 2017-04-02T00:10:01-07:00
Now I use following approach for accessing to image pixel colors:
I should to process about 5000 images like that. It takes me about 3-4 seconds to just get all the pixels of one image (1920x1080). Are there any methods which work a little bit faster than that?
I use ImageMagick 7.0.5-2 Q16 x86_64 2017-03-11.
Code: Select all
unsigned short _imgWidth = 1920, _imgHeight = 1080;
Magick::Image *image = new Magick::Image();
image->size( Magick::Geometry( _imgWidth, _imgHeight ) );
image->backgroundColor( Magick::Color( "white" ) );
image->erase();
for ( unsigned int j = 0; j < _imgHeight; j++ ) {
for ( unsigned int i = 0; i < _imgWidth; i++ ) {
Magick::Color c = image->pixelColor( i, j );
unsigned char r = c.quantumRed() * 255 / QuantumRange;
unsigned char g = c.quantumGreen() * 255 / QuantumRange;
unsigned char b = c.quantumBlue() * 255 / QuantumRange;
}
}
delete image;
I use ImageMagick 7.0.5-2 Q16 x86_64 2017-03-11.