使用 simd 指令時,32 位圖像處理是否比 24 位圖像處理快? (Is 32 bit image processing faster than 24 bit image processing when simd instructions are used?)


問題描述

使用 simd 指令時,32 位圖像處理是否比 24 位圖像處理快? (Is 32 bit image processing faster than 24 bit image processing when simd instructions are used?)

I had a look on the sse and mmx instruction set and there are no instructions for 3 channel image processing. Of course, for many operations you can use the same instructions, such as averaging two images. But when it comes to operations like unshuffling the channels or mixing different channels by a linear transformation, it seems a lot easier to use 32 bit images. 

How are the performance chararteristics of typical image processing tasks with 24 vs. 32 bit images?


參考解法

方法 1:

24 bit/pixel are faster if your images are large and the operations are simple (such as alpha-blending etc).

Very often the operations in image processing are quite simple, but you execute millions of them. So the time used to move data in and out from main-memory to the CPU can easily dominate the performance of an algorithm.

Therefore 24 bit/pixel images can offer an advantage over 32 bit/pixel images because there is 1/4 less data to move around.

Writing image-processing code that performs well with 24 bit/pixel is a pain though. The SSE instructions don't really fit the data, so you have to shuffle bytes around, and then you have to deal with all the different alignments.

If the images you are working with are small and fit in the l1 or l2 cache, things are different and the CPU time will dominate the performance. In these cases 32 bit/pixel performs faster.

方法 2:

On new x86 CPUs with PSHUFB (aka _mm_shuffle_epi8) splitting the channels can be done in few cycles, and it can be cheaper than incurring additional memory accesses due to extending pixel width to 32 bits. On old x86 CPUs without PSHUFB it requires a lot of shuffles or unpacking instructions, and 32-bit pixels are much more efficient.

On ARM CPUs with NEON splitting the channels can be done for free by the load-store unit. On ARM CPUs without NEON splitting the channels can be done with ARMv6 SIMD instructions at the cost of about 3 instructions per pixel.

(by Ralph TandetzkyNils PipenbrinckMarat Dukhan)

參考文件

  1. Is 32 bit image processing faster than 24 bit image processing when simd instructions are used? (CC BY-SA 3.0/4.0)

#image-processing #sse #performance #24-bit #simd






相關問題

在 matlab 中用 imread 讀取圖像文件會給出什麼樣的表示? (reading a image file with imread in matlab gives what kind of representation?)

使用 CRF 的圖像標記性能 (Image labeling performance using CRF)

Opencv:獲取圖像中的段大小並刪除小段 (Opencv: Get segments sizes in image and remove small segments)

將 PHP 頁面作為圖像返回 (Return a PHP page as an image)

我在哪裡可以找到有關雙三次插值和 Lanczos 重採樣的好讀物? (Where can I find a good read about bicubic interpolation and Lanczos resampling?)

從圖像中刪除白色背景 (Remove white backgrounds from images)

如何填充投影圖像的空白部分? (How to fill empty parts of a projected image?)

如何使圖像亮度均勻(使用 Python/PIL) (How to Make an Image Uniform Brightness (using Python/PIL))

圖像處理公式可生成類似通過 Mac 相機拍攝的照片的效果 (Image manipulation formula to generate effects like pictures taken via Mac's camera)

從照片生成漂亮的直方圖? (generating nice looking histogram from photo?)

使用 DjVu 工具進行背景/前景分離? (Using the DjVu tools to for background / foreground seperation?)

如何操縱跟踪器區域使其變成方形? (How can I manipulate the tracker area to make it into a square shape?)







留言討論