Skip to content

support indexed color images on iOS#17636

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
okamotoR:3.4
Jun 27, 2020
Merged

support indexed color images on iOS#17636
opencv-pushbot merged 1 commit intoopencv:3.4from
okamotoR:3.4

Conversation

@okamotoR
Copy link
Copy Markdown
Contributor

@okamotoR okamotoR commented Jun 23, 2020

UIImageToMat() fail to convert indexed color image now.
This is because CGBitmapContextCreate() in UIImageToMat() don't support indexed color spaces.
I added if block for indexed color spaces.

CGBitmapContextCreate
https://developer.apple.com/documentation/coregraphics/1455939-cgbitmapcontextcreate?language=objc

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [○] I agree to contribute to the project under OpenCV (BSD) License.
  • [○] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • [○] The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [○] The feature is well documented and sample code can be built with the project CMake

@alalek
Copy link
Copy Markdown
Member

alalek commented Jun 25, 2020

/cc @vpisarev @komakai Could you please take a look on this patch?

Copy link
Copy Markdown
Contributor

@komakai komakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okamotoR looks basically good - a few questions:

  • can you share steps to create a UIImage with color space kCGColorSpaceModelIndexed? (so I can test it)
  • m = cv::Scalar(0); is this the correct way to handle the case alphaExist == true? (or is it just copy/pasted from the kCGColorSpaceModelMonochrome block)
  • are there any other color spaces that should be handled by this function?

Thanks

@okamotoR
Copy link
Copy Markdown
Contributor Author

Thank you for reviewing.

I created UIImage on swift from https://en.wikipedia.org/wiki/Indexed_color.
Then I used UIImagePickerController.

I copy/pasted from not kCGColorSpaceModelMonochrome block but else block
because CGColorSpaceCreateDeviceRGB() make RGBColorSpace.

I think this function has no problem now for other color spaces.

@komakai
Copy link
Copy Markdown
Contributor

komakai commented Jun 27, 2020

@okamotoR ありがとう!
I was able to test the code and can confirm it is working.

Copy link
Copy Markdown
Contributor

@komakai komakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution 👍

@komakai Thank you for review!

@opencv-pushbot opencv-pushbot merged commit cabad90 into opencv:3.4 Jun 27, 2020
@okamotoR
Copy link
Copy Markdown
Contributor Author

Thank you very much.

@alalek alalek mentioned this pull request Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants