Fastest anti-aliasing / halftone library in C

I am developing a user server with a thin client that serves the provided web pages to its clients. The server runs in a multi-core Linux box, with Webkit providing a html rendering engine.

The only problem is that the client display is limited to four (16 colors) gray palettes. I am currently using LibGraphicsMagick to smooth images (RGB-> 4bit grayscale), which is an obvious bottleneck in server performance. Profiling shows that over 70% of the time is spent on the smoothing features of GraphicsMagick.

I researched stackoverflow and Interwebs for a good high-performance solution, but no one seems to have done any tests in various image processing libraries and anti-aliasing solutions.

I would be happier to know:

  1. What are the libraries with the highest performance in terms of smoothing / grayscale / quantize RGB images to 4 shades of gray.
  2. Are there any special anti-aliasing libraries or any code fragments of the public domain that you could point me to?
  3. Which libraries do you prefer for managing graphics for high performance?

C libraries are preferred.

+5
source share
4 answers

.

Bayer (Matrix) Floyd -Steinberg (Diffusion) .

Bayer MMX/SSE . / .

FWIW, GraphicsMagick, OSS

+2

, Adisak, - , AfterImage. Afterstep , .

, PCI-Express OpenGL. Nvidia. " " . , 16 256 , (, ), .

OpenGL , , , PCI-Express. , .

+2

, C, , .NET, -, 20 . , , .

But try to be helpful :) I found this C library .

+1
source

Here is the implementation of the Floyd-Steinberg method for halftoning:

#include <opencv2/opencv.hpp>

using namespace cv;

int main(){

uchar scale = 128; // change this parameter to 8, 32, 64, 128 to change the dot size
Mat img = imread("../halftone/tom.jpg", CV_LOAD_IMAGE_GRAYSCALE);
for (int r=1; r<img.rows-1; r++) {
    for (int c=1; c<img.cols-1; c++) {
        uchar oldPixel = img.at<uchar>(r,c);
        uchar newPixel = oldPixel / scale * scale;
        img.at<uchar>(r,c) = newPixel;
        int quantError = oldPixel - newPixel;
        img.at<uchar>(r+1,c)   +=  7./16. * quantError;
        img.at<uchar>(r-1,c+1) +=  3./16. * quantError;
        img.at<uchar>(r,c+1) +=  5./16. * quantError;
        img.at<uchar>(r+1,c+1) +=  1./16. * quantError;
    }
}
imshow("halftone", img);
waitKey();
}
+1
source

All Articles