Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image processing #33

Open
jjjkkkjjj opened this issue Jul 19, 2022 · 5 comments
Open

Image processing #33

jjjkkkjjj opened this issue Jul 19, 2022 · 5 comments

Comments

@jjjkkkjjj
Copy link
Owner

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
Copy link
Owner Author

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
Copy link
Owner Author

jjjkkkjjj commented Jul 20, 2022

let contextRef = CGContext(data: $0.baseAddress!, width: width, height: height, bitsPerComponent: 8, bytesPerRow: width*channel, space: colorSpace, bitmapInfo: bitmapInfo.rawValue)

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
Copy link
Owner Author

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
Copy link
Owner Author

@jjjkkkjjj
Copy link
Owner Author

jjjkkkjjj commented Jul 21, 2022

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 added a commit that referenced this issue Jul 23, 2022
* support float image

* togray

* add playground

* exclude_alpha bug fixed

* save

* cgimage2mfarray bug fixed

* update Demo

* resize

* check_and_convert_image_dim bug fixed

* update demo and README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant