Manipulate Bitmap in DSP Code

For general discussion related FlowStone
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Manipulate Bitmap in DSP Code

Post by aronb »

Hi,

I need to manipulate a small Bitmap (128 x 128 pixels max) fast, and was wondering if a Bitmap (image array) can be "loaded" into the DSP Code Module and accessed that way.

For example to extract color information from a particular pixel location... think of it like "GetPix" (Get Pixel) but way faster than green modules ?

I want to use a Bitmap Image for audio waveform manipulation, and vise versa 8-)

Thanks,

Aron
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Manipulate Bitmap in DSP Code

Post by martinvicanek »

You could load the Bitmap into mem and then manipulate it using wave read, code and analyzer. However, to display the result you'd have to convert back to bitmap, which is slow.
User avatar
aronb
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA
Contact:

Re: Manipulate Bitmap in DSP Code

Post by aronb »

Martin,

Can you explain a bit more please, step by step :?

Would I still use the GetPix primitive and write it to an array then to mem then to DSP ?

Thank you very much for the help,

Aron
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Manipulate Bitmap in DSP Code

Post by martinvicanek »

Here is a demo. It is fairly complicated, dunno if there is an easier way.
Edit: fixed initialization issue (thanks tulamide for pointing it out!)
Attachments
ImageProcessing_fixed.fsm
(41.83 KiB) Downloaded 1131 times
Last edited by martinvicanek on Tue May 24, 2016 6:54 pm, edited 1 time in total.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Manipulate Bitmap in DSP Code

Post by tulamide »

martinvicanek wrote:Here is a demo. It is fairly complicated, dunno if there is an easier way.

Is it supposed to change something when turning the brightness knob? Or does it need additional modules/prims to work? I added and activated an asio out, but nothing happened.

My two cents:
The main idea is good. Convert the bitmap to an array once, store changes to the array and only convert the array back to a bitmap when a redraw is needed. Might be doable with Ruby as well, but the main downside is that we can't make use of the graphics card's power, especially the 2d shaders.
"There lies the dog buried" (German saying translated literally)
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Manipulate Bitmap in DSP Code

Post by martinvicanek »

For the brightness knob to work you might have to press some of the triggers inside the module in some order. :oops:
Yes, I suppose you could do most of the first part, the bitmap to mem conversion, in Ruby. I might upload a more interesting demo later on.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Manipulate Bitmap in DSP Code

Post by martinvicanek »

The above demo features a very simple brightness adjustment. It has clipping artifacts which result in hue distortion. Do not use for serious image processing!
Perhaps a more useful application is attached below. It demoes a control for hue rotation, which might be handy if you want to dynamically sweep the color of a LED from green to red, say, with all nuances of yellow and orange (Spogg, are you reading this? :lol: ) in between.
@aronb, what kind of image manipulation did you have in mind?
Attachments
ImageProcessingHue.fsm
Fixed initialization after duplicate
(108.24 KiB) Downloaded 1115 times
Last edited by martinvicanek on Wed May 25, 2016 8:13 pm, edited 1 time in total.
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Manipulate Bitmap in DSP Code

Post by Spogg »

martinvicanek wrote:... orange (Spogg, are you reading this? :lol: ).


If the poster is you Martin, I always read it! Especially if orange is involved.

I love this demo but I had a strange issue. I put the whole thing into a module with graphics enabled (so I could put it into my toolbox whole) and it stopped working. I added an ASIO prim. Still not. So I took it out of the module and it still failed to work. Restarted FS and reloaded the module and it worked. Then repeated the above with the same result. I did try the trigger switch but I couldn't revive the function. Never seen this behaviour before.
What am I doing wrong? I bet I'm going to feel foolish quite soon...

Cheers

Spogg
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Manipulate Bitmap in DSP Code

Post by kortezzzz »

@spogg

+1

Seems like the order of the triggers that being sent to the bitmap prim's should be carefully determined, or you loose the functionality for some reason.

@martin, thanks for this. very interesting schematic.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Manipulate Bitmap in DSP Code

Post by martinvicanek »

The problem was that the output bitmap memory allocation was not retriggered after duplicate. Fixed now.
Post Reply