Images for real time spectrogram: how to change CData partially in an efficient way?

16 views (last 30 days)
oscarcot
oscarcot on 20 Sep 2011
Hi,
I have a GUI application that samples and displays 24 channels at 12 kHz. The application can also calculate and plot the FFT's (1024,2048 points) in real time. Thanks to the set(plot1,'Xdata',x,'Ydata',y) command, my plots update pretty fast.
Now, I want to implement a 24 channel spectrogram view. As you can imagine, this is amazingly time- and memory-consuming. I had in mind placing 24 image-views and doing something similar by using the set(image1,'Cdata', spec) command. What I don't like, is that each 'spec' variable has to be an MxN matrix, while I only need to update 1 column at each time!
Is there some way to change ONLY ONE COLUMN of CData?
I saw there is a colors=get(image1,'CData') function, where I can retrieve the CData matrix, modify it, and then place it back into the 'CData property'. I haven't tried it yet, but I'm afraid that moving the whole image back and forth takes a lot of time.
Could somebody give me an advice?
1. How can I partially alter "CData"? 2. Is the "get" command my only alternative? 3. Is it fast/efficient enough for my spectrogram application?
Kind regards, Oscar

Answers (2)

Walter Roberson
Walter Roberson on 20 Sep 2011
get(), modify, set(), is the only supported mechanism.
There might possibly be mechanisms in the private details of how handle graphics work, or there might possibly be mechanisms involving Java methods.

Patrick Kalita
Patrick Kalita on 21 Sep 2011
Don't assume you have a performance problem before you do. Try the C = get(image1, 'CData'), modify C, set(image1, 'CData', C) workflow first and see whether it is fast enough for your application.
If it is too slow, it is possible that you could break up the image into several smaller images. For instance, instead of one 1024x2048 image you could have sixteen 1024x128 images. Now you're moving around a smaller array when you need to do an update. The cost is that you need to do some extra bookkeeping to know which image to update and you'll need to setup the XData and YData of each image appropriately so they all line up nicely.
I haven't tried this out, so I don't make any guarantees. It's just an idea.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by