Ask Your Question

Base64 to source 8-bit single-channel image 'OpenCV.js'

asked 2018-05-22 07:53:08 -0500

tom gravatar image

I am trying to implement adaptive treshholding on my client device.

I am using Ionic 2 and here I need to use a base64 string. When I try to optimalise my image using adaptive treshholding using Opencv.js the method requires a source 8-bit single-channel image.

Can anyone provide me with information on how to convert the base64 string to a source 8-bit singe-channel image and back again ?

edit retag flag offensive close merge delete


opencv.js takes it's images from a canvas, so, if you're able to upload your base64 encoded image there, you've won. (i don't think, you need to convert it)

berak gravatar imageberak ( 2018-05-22 08:30:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-05-24 01:31:03 -0500

rishant gravatar image

updated 2018-05-24 01:32:27 -0500

Since images are stored as Mat, you can create a new Mat using matfromarray function and use image data and dimensions from old ones, also supply the flag CV_8UC1 which means 8bit 1 channel.

edit flag offensive delete link more


hmm, imho your idea would also require to base64_decode the string, followed by something like imdecode() , no ?

i don't use ionic, but i guess, what they output there is a "data url", containing a base64 encoded image, not a Mat, more like a jpg on disk

berak gravatar imageberak ( 2018-05-24 01:55:56 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-05-22 07:53:08 -0500

Seen: 177 times

Last updated: May 24 '18