Ask Your Question
0

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

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

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

Comments

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

rishant gravatar image

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

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

Comments

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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,492 times

Last updated: May 24 '18