comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Running this MATLAB code in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Running this MATLAB code in IDL [message #88429] Thu, 24 April 2014 03:39 Go to next message
mikejohnryan08 is currently offline  mikejohnryan08
Messages: 5
Registered: April 2014
Junior Member
Hello,

What would be the best way to run this MATLAB code in IDL (http://www.ee.cuhk.edu.hk/~snli/MATLAB_code.zip) which creates a 3d red/blue anaglyph from two images?

Also, since this is a code from an academic source, would I be able to use this to build onto for a more involved program for a masters thesis as long as I source the code's author in my report?

Thanks!
Re: Running this MATLAB code in IDL [message #88436 is a reply to message #88429] Thu, 24 April 2014 13:25 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/24/14, 4:39 AM, mikejohnryan08@gmail.com wrote:
> Hello,
>
> What would be the best way to run this MATLAB code in IDL
> (http://www.ee.cuhk.edu.hk/~snli/MATLAB_code.zip) which creates a 3d
> red/blue anaglyph from two images?

You want to launch Matlab and run your code? SPAWN is the only way I
know of doing that.

I have a very simple class to create red/cyan or red/blue anaglyphs in
my library (github.com/mgalloy/mglib) at:

https://github.com/mgalloy/mglib/blob/master/src/vis/objectg raphics/mggr3dconverter__define.pro

Call the ::_combineImages method to create the anaglyph image. But if
you already have the two images, there is not much to it -- I would just
use my code as a guide and write your own.

> Also, since this is a code from an academic source, would I be able
> to use this to build onto for a more involved program for a masters
> thesis as long as I source the code's author in my report?

For questions like these, check the license of the code which is either
in comments at the top of the code or in a LICENSE/COPYING/README type
file. In your case, the code has this comment:

%Copyright(c) 2013 Li Songnan
%All Rights Reserved.

Do not use, although you could always ask the author for special permission.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
Re: Running this MATLAB code in IDL [message #88439 is a reply to message #88436] Thu, 24 April 2014 20:42 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Thursday, April 24, 2014 4:25:25 PM UTC-4, Mike Galloy wrote:
>> Also, since this is a code from an academic source, would I be able
>> to use this to build onto for a more involved program for a masters
>> thesis as long as I source the code's author in my report?
>
>
>
> For questions like these, check the license of the code which is either
> in comments at the top of the code or in a LICENSE/COPYING/README type
> ...

Beyond simple licensing rights, you really need to speak with your Master's advisor about what is the appropriate level of work for your project.

As a purely practical matter, I think it would be a little nuts to mix IDL and Matlab. These are not languages that were designed to talk to each other, and both languages have strange quirks. And then there is the question of audience. Few people have Matlab, even fewer have IDL, and a vanishingly small number of people have both. I recommend sticking with one language.

CM
Re: Running this MATLAB code in IDL [message #88448 is a reply to message #88436] Sun, 27 April 2014 18:00 Go to previous messageGo to next message
mikejohnryan08 is currently offline  mikejohnryan08
Messages: 5
Registered: April 2014
Junior Member
On Thursday, April 24, 2014 4:25:25 PM UTC-4, Mike Galloy wrote:
> On 4/24/14, 4:39 AM, mikejohnryan08@gmail.com wrote:
>
>> Hello,
>
>>
>
>> What would be the best way to run this MATLAB code in IDL
>
>> (http://www.ee.cuhk.edu.hk/~snli/MATLAB_code.zip) which creates a 3d
>
>> red/blue anaglyph from two images?
>
>
>
> You want to launch Matlab and run your code? SPAWN is the only way I
>
> know of doing that.
>
>
>
> I have a very simple class to create red/cyan or red/blue anaglyphs in
>
> my library (github.com/mgalloy/mglib) at:
>
>
>
> https://github.com/mgalloy/mglib/blob/master/src/vis/objectg raphics/mggr3dconverter__define.pro
>
>
>
> Call the ::_combineImages method to create the anaglyph image. But if
>
> you already have the two images, there is not much to it -- I would just
>
> use my code as a guide and write your own.
>
>
>
>> Also, since this is a code from an academic source, would I be able
>
>> to use this to build onto for a more involved program for a masters
>
>> thesis as long as I source the code's author in my report?
>
>
>
> For questions like these, check the license of the code which is either
>
> in comments at the top of the code or in a LICENSE/COPYING/README type
>
> file. In your case, the code has this comment:
>
>
>
> %Copyright(c) 2013 Li Songnan
>
> %All Rights Reserved.
>
>
>
> Do not use, although you could always ask the author for special permission.
>
>
>
> Mike
>
> --
>
> Michael Galloy
>
> www.michaelgalloy.com
>
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
>
> Research Mathematician
>
> Tech-X Corporation


Thanks for the responses! I agree that it would not be a good idea to attempt using the MATLAB code in any way towards thesis research, and that it would be better to write my own simple IDL function to do this.

Mike, thanks for pointing me towards your code library. The "combineImages" method from your anaglyph class seems to be EXACTLY what I am trying to implement in IDL, and seems like it would be a very basic function; since as you said, I already have the left and right images. But since I am completely new to IDL, I can't even begin to think about how that method could be turned into a standalone function. It should be very basic, right?

Thanks again!
Re: Running this MATLAB code in IDL [message #88449 is a reply to message #88448] Sun, 27 April 2014 18:20 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/27/14, 7:00 pm, mikejohnryan08@gmail.com wrote:
> Thanks for the responses! I agree that it would not be a good idea
> to attempt using the MATLAB code in any way towards thesis research,
> and that it would be better to write my own simple IDL function to do
> this.
>
> Mike, thanks for pointing me towards your code library. The
> "combineImages" method from your anaglyph class seems to be EXACTLY
> what I am trying to implement in IDL, and seems like it would be a
> very basic function; since as you said, I already have the left and
> right images. But since I am completely new to IDL, I can't even
> begin to think about how that method could be turned into a
> standalone function. It should be very basic, right?

Methods have access to the instance variables of the object and can call
other methods of the object using the "self" variable, so watch out for
them. In the _combineImages example, there was only the self.color
variable, so how about something like:

function mg_create_anaglyph, leftImage, rightImage, color=color
compile_opt strictarr

; define combined_image to the correct size
combinedImage = leftImage * 0B
dims = size(leftImage, /dimensions)

if (keyword_set(color)) then begin
combinedImage[0, *, *] = leftImage[0, *, *]
combinedImage[1, *, *] = rightImage[1, *, *]
combinedImage[2, *, *] = rightImage[2, *, *]
endif else begin
_leftImage = byte(total(fix(leftImage), 1) / 3)
_rightRight = byte(total(fix(rightImage), 1) / 3)

combinedImage[0, 0, 0] = Reform(_leftImage, 1, dims[1], dims[2])
combinedImage[1, 0, 0] = Reform(_rightRight, 1, dims[1], dims[2])
combinedImage[2, 0, 0] = Reform(_rightRight, 1, dims[1], dims[2])
endelse

return, combinedImage
end

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
Re: Running this MATLAB code in IDL [message #88455 is a reply to message #88449] Mon, 28 April 2014 19:04 Go to previous message
mikejohnryan08 is currently offline  mikejohnryan08
Messages: 5
Registered: April 2014
Junior Member
On Sunday, April 27, 2014 9:20:16 PM UTC-4, Mike Galloy wrote:
> On 4/27/14, 7:00 pm, mikejohnryan08@gmail.com wrote:
>
>> Thanks for the responses! I agree that it would not be a good idea
>
>> to attempt using the MATLAB code in any way towards thesis research,
>
>> and that it would be better to write my own simple IDL function to do
>
>> this.
>
>>
>
>> Mike, thanks for pointing me towards your code library. The
>
>> "combineImages" method from your anaglyph class seems to be EXACTLY
>
>> what I am trying to implement in IDL, and seems like it would be a
>
>> very basic function; since as you said, I already have the left and
>
>> right images. But since I am completely new to IDL, I can't even
>
>> begin to think about how that method could be turned into a
>
>> standalone function. It should be very basic, right?
>
>
>
> Methods have access to the instance variables of the object and can call
>
> other methods of the object using the "self" variable, so watch out for
>
> them. In the _combineImages example, there was only the self.color
>
> variable, so how about something like:
>
>
>
> function mg_create_anaglyph, leftImage, rightImage, color=color
>
> compile_opt strictarr
>
>
>
> ; define combined_image to the correct size
>
> combinedImage = leftImage * 0B
>
> dims = size(leftImage, /dimensions)
>
>
>
> if (keyword_set(color)) then begin
>
> combinedImage[0, *, *] = leftImage[0, *, *]
>
> combinedImage[1, *, *] = rightImage[1, *, *]
>
> combinedImage[2, *, *] = rightImage[2, *, *]
>
> endif else begin
>
> _leftImage = byte(total(fix(leftImage), 1) / 3)
>
> _rightRight = byte(total(fix(rightImage), 1) / 3)
>
>
>
> combinedImage[0, 0, 0] = Reform(_leftImage, 1, dims[1], dims[2])
>
> combinedImage[1, 0, 0] = Reform(_rightRight, 1, dims[1], dims[2])
>
> combinedImage[2, 0, 0] = Reform(_rightRight, 1, dims[1], dims[2])
>
> endelse
>
>
>
> return, combinedImage
>
> end
>
>
>
> Mike
>
> --
>
> Michael Galloy
>
> www.michaelgalloy.com
>
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
>
> Research Mathematician
>
> Tech-X Corporation

Thanks, that makes much more sense now. I was confused about where the self.color was coming from but now I understand. This is very helpful advice for kickstarting my research project, I certainly appreciate it.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FFT and Parseval
Next Topic: Smooth and /EDGE_TRUNCATE

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:22:26 PDT 2025

Total time taken to generate the page: 0.00502 seconds