Prev: Problem with GUI
Next: help me on matlab MEX
From: Chen Zhao on 7 Jul 2010 13:35 Hi, I don't have the image processing toolbox, but I'd like to be able to efficiently update an image. For example, I have a large two-dimensional array and I display the image using the image function. I want to change just one or two of elements of this array and update the image. Redrawing everything would take too much time, so is there a way to redraw those specific pixels? The way my program is set up is it updates a small part (maybe a few pixels) of a large gray-scale image (1920 x 1080) in a loop. In every loop, a very small part of the image will change. Therefore, you can see that redrawing everything will take a lot of time. Thanks for any help. Chen
From: Image Analyst on 7 Jul 2010 14:48 Chen: No, it shouldn't take a long time - it should be lightning fast. Just calling imshow() or image() for a 1920 by 1080 image would be very fast. There is no way, or need to redraw just a part of it. If your loop is slow, I suggest you look elsewhere for the bottleneck. Try using the profiler tool. By the way, 1920 by 1080 (2 MB) is not large at all by the way, not by a long shot. Just a run of the mill digital camera will produce images like 4000 by 3000. I have some monochrome images that are 9000 x 7000 (64 MB) and I have some 3D CT images which are up to 20,000 MB in size. So don't worry about that 2 MB size - it's not large at all and it should display very quickly. -ImageAnalyst
From: Walter Roberson on 7 Jul 2010 15:20 Chen Zhao wrote: > I don't have the image processing toolbox, but I'd like to be able to > efficiently update an image. > > For example, I have a large two-dimensional array and I display the > image using the image function. I want to change just one or two of > elements of this array and update the image. Redrawing everything would > take too much time, so is there a way to redraw those specific pixels? > > The way my program is set up is it updates a small part (maybe a few > pixels) of a large gray-scale image (1920 x 1080) in a loop. In every > loop, a very small part of the image will change. Therefore, you can see > that redrawing everything will take a lot of time. Create the image. Set its EraseMode property to 'none'. To update the image, patch() the revised pixels into their proper location and then delete the patch object: because of the EraseMode 'none', deleting the patch object will not remove the changes from the screen, but with the patch object gone then Matlab will not have to check later changes against the patch to see if there is an intersection. I don't promise that this will be faster, as Matlab makes no commitments about the relative speeds of redrawing a whole area (which can probably be done just by DMA) compared to adding a new object to the rendering hierarchy (the cost of which would depend partly upon the renderer you have chosen.) You might also be able to get a speedup by using the painters renderer with the axes property DrawMode set to 'fast', but the various documentation _suggests_ that OpenGL will usually be much faster if you have the hardware support for it.
From: Chen Zhao on 7 Jul 2010 18:58 Thank you, Walter. I tried using patch() and it seems to work really well. Chen
|
Pages: 1 Prev: Problem with GUI Next: help me on matlab MEX |