Matft icon indicating copy to clipboard operation
Matft copied to clipboard

Image processing

Open jjjkkkjjj opened this issue 2 years ago • 5 comments

Create OpenCV Mat by https://stackoverflow.com/questions/39579398/opencv-how-to-create-mat-from-uint8-t-pointer

and pass it by “with” statements.

simple image processing function is vImage Module

FFFF means float types (8888 means UInt8)

https://developer.apple.com/documentation/accelerate/1515929-vimageconvolve_argbffff

jjjkkkjjj avatar Jul 19 '22 23:07 jjjkkkjjj

https://docs.opencv.org/3.1.0/d3/d63/classcv_1_1Mat.html#a5fafc033e089143062fd31015b5d0f40

Pointer to the user data. Matrix constructors that take data and step parameters do not allocate matrix data. Instead, they just initialize the matrix header that points to the specified data, which means that no data is copied. This operation is very efficient and can be used to process external data using OpenCV functions. The external data is not automatically deallocated, so you should take care of it.

jjjkkkjjj avatar Jul 19 '22 23:07 jjjkkkjjj

https://github.com/jjjkkkjjj/Matft/blob/7bd5406b1286f7ac4d002be07cab847ba32349bd/Sources/Matft/library/vDSP.swift#L1415

bitspercomponent = 32 means float? If so, this is more efficient

According to core graphics supposed pixel formats, it only supports RGB with float format on iOS not Gray on iOS

ref: CGContext

jjjkkkjjj avatar Jul 20 '22 00:07 jjjkkkjjj

I think CGContext documents implies passing data pointer will not be freed (= not copied )

data: A pointer to the destination in memory where the drawing is to be rendered. The size of this memory block should be at least (bytesPerRow*height) bytes. Pass NULL if you want this function to allocate memory for the bitmap. This frees you from managing your own memory, which reduces memory leak issues.

jjjkkkjjj avatar Jul 20 '22 00:07 jjjkkkjjj

Ref: Float CGContext

https://stackoverflow.com/questions/55433107/how-to-normalize-pixel-values-of-an-uiimage-in-swift

jjjkkkjjj avatar Jul 20 '22 14:07 jjjkkkjjj

The difference between Planar and interleaved image link Planar: Column contiguous Interleaved: Row contiguous

https://developer.apple.com/documentation/accelerate/optimizing_image-processing_performance

jjjkkkjjj avatar Jul 21 '22 15:07 jjjkkkjjj