Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Arithmetic deduction/extraction
Posted:
Apr 12, 2013 1:26 PM


"kees de Kapper" <kees_de_kapper@hotmail.com> wrote in message news:kk75u5$kf5$1@newscl01ah.mathworks.com... > Thanks for replying. I'm going to look into it. > > What I'm trying to make is a simple way for users to apply arithmetic > operation of loaded images. I've created an ImageObject that contains > multiple properties and methods which make the use of images much more > elegant. If I have to do Arithmetic operations it is now very easy and > robust. Now, I'd like to enable this "interface" for users. If a user now > writes "2*Img1+Img3/Img5" I need to extract all the operations and > excecute some methods/functions for example cropping, transformations etc. > "Img1*2" is straight forward to extract, but "(2*Img1+Img2)/3" is not. > Could this easily be done in Matlab?
Could this be done? Yes. Could this _easily_ be done? Yesssssssssss, I can think of a way to apply those formulae to the images ... but doing so would require using EVAL and I discourage you from doing that because that's handing a loaded weapon to your users.
Since you said you're doing this in a GUI (dialog) have you considered putting buttons for the arithmetic operations you want to support on the GUI itself? That way you allow your users to only manipulate the images using the arithmetic operations YOU give them rather than giving them the freedom to do anything (what happens if your user types a system command into your dialog, such as the command to format the hard drive?) There's an example in Symbolic Math Toolbox, FUNTOOL, that does basically what I'm thinking.
http://www.mathworks.com/help/symbolic/funtool.html
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



