imroi: bloated Matlab commands

I was working with rbbox on my Matlab GUI application to create squares that marked important stuff inside an image.  I recently needed to move away from the rectangle based approach to a polygon based approach.  This meant not using rbbox.  I found cool im* commands that did what I needed.  These commands include imrect, impoly and imfreehand.

Today I pretty much finished the coding of the new version (with some little issues to resolve).  When I did my final tests, I noticed that the new version lagged just a little when doing annotation actions (creating, moving, deleting…).  I took this a bit further and did a very simple “top” based test to compare two versions of the GUI. The first version is the current one that implements the annotations with im* commands.  And the other version is the one that I replaced that used the rbbox command.

Matlab command comparison

Matlab command comparison

In the figure, red line means the execution with the rm* functions, blue means rbbox.  Notice that at the begining there is a spike that is comparable in the two cases.  This is the GUI initialization.

In both lines there is a second spike that represents the start of a rectangle creation.  Notice that the imrect (red) command uses 100% of one of my CPUs while the rbbox uses 50% approx.

After I created the rectangle I stretched it a bit before finalizing the tests.  Notice that the stretch action in the imrect line (red) is eating at my CPU.  It has a second spike that reaches close to 100%.  While the rbbox line (blue) has a milder footprint and does not go past 50%.

So: What is imrect doing that eats up most of my CPU?  I have no idea :(. But it’s annoying.  One explanation could be the extra functionality that im* functions bring to the GUI.  But given the performance of rbbox, I’m left with the impression that it could be done better.

Advertisements

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in annotation, commands and tagged . Bookmark the permalink.

7 Responses to imroi: bloated Matlab commands

  1. yavuz says:

    please help me for matlab image processing. my mail adres: yavuzunalnet@gmail.com

  2. yavuz says:

    hi, pls give me idea how for medical images for neural network based segmentation. ihave to the lumbar MR images. pls help me.

  3. Hi
    Can you please let me know how to use imroi command. The ROi I would like to extract is irregular in shape I am willing to read only that section . is it possible using imroi. what is the sequence of commands. what is h and h_im here. How to create mask.

  4. I’ve experienced this issue! (Currently am experiencing it now)
    Imroi and all the im* functions in MATLAB use so much processing power that my MacBook’s fan is on full! Haven’t found an explanation for the code inefficiency though :/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s