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

Home » Public Forums » archive » JPEG image help - Easy for people who understand 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
JPEG image help - Easy for people who understand IDL?! [message #82299] Thu, 06 December 2012 14:08 Go to next message
Rebecca C is currently offline  Rebecca C
Messages: 5
Registered: December 2012
Junior Member
Hi,
I'm not really sure what this group is for but I'm hoping someone who understands IDL can see this and help me! Thanks in advance for reading on :)

So, I'm in "Intro to IDL" class, and understand mostly nothing.
We are given two files, one "ocean.jpg" and the other "sky.jpg". The question is to merge the two jpegs so one is on top, and the other on bottom, and to save this jpg.

Here is the procedure I have:

PRO jpghomework

file='sky.jpg'
read_JPEG,file,sky

file2='ocean.jpg'
read_JPEG,file2,ocean

tv,sky,true=1
tv,ocean,true=1

end

I have been trying to read and figure this out for two days, and it is due soon. Our professor is nonexistent (unreachable, no course material etc) so please think of this as I'm just a person who knows nothing about IDL, has Google, and the IDL workstation in front of me to try things out.

And, the homework question of course.

Thank you so much in advance! - Rebecca
Re: JPEG image help - Easy for people who understand IDL?! [message #82387 is a reply to message #82299] Thu, 06 December 2012 16:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> Also, my major is environmental science, "Society and Policy" track. *Not* the scientific/lab work track. I've taken two ArcGIS-related classes, and can operate that software alright to make maps and some tables. That's about as technical as I've ever had to get - IDL is quite the wrong fit for me!
>
> I'm headed out of the computer lab now, but I will be back on Tuesday. I would love to revisit this if I don't figure it out by then, so if you post your 3-line supermethod (or should I call it pure magic) I would definitely be grateful.

OK, here is my solution, then. When you get questioned
about whether this is your own work or not, just
say "I went to sleep the other night, and the answer
came to me in a dream. It was like I was channeling
Kekulé's structure of benzene!"

If you don't know who Kekulé is, you better bone
up on that whole snake chasing its tail business:

http://www.ch.ic.ac.uk/rzepa/mim/environmental/html/benzene. htm

Here it is:

cgImage, Filename='sky.jpg', /Window, WMULTI=[0,1,2]
cgImage, Filename='ocean.jpg', /AddCmd
cgControl, Output='combined_sky_ocean.jpg'

Good luck with this. You will owe me a beer when
I run into you at the big AGU meeting in San Francisco
next year!

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82388 is a reply to message #82299] Thu, 06 December 2012 16:29 Go to previous message
Rebecca C is currently offline  Rebecca C
Messages: 5
Registered: December 2012
Junior Member
Yes, re-bin definitely does not seem like what I was intending to do. And, for the assignment, I don't think it is necessary. I battled with "congrid" earlier this morning, before also ditching it. In fact, I no longer care about resizing them as long as I got the two images into a .jpg ... even if by my workaround way!

I have already submitted the .pro (pretty much the same as I had pasted above) and the resulting jpg to my professor and am waiting for his response. All we were supposed to give was the JPG, but I *know* that I still don't understand the real way to do it so was just poking around to get an actual grasp of it! I don't think stumbling my way to a correct end result is as important as understanding the right way to get there.

Also, my major is environmental science, "Society and Policy" track. *Not* the scientific/lab work track. I've taken two ArcGIS-related classes, and can operate that software alright to make maps and some tables. That's about as technical as I've ever had to get - IDL is quite the wrong fit for me!

I'm headed out of the computer lab now, but I will be back on Tuesday. I would love to revisit this if I don't figure it out by then, so if you post your 3-line supermethod (or should I call it pure magic) I would definitely be grateful. Some people may be around next week in my department who I could ask about this and a couple other questions, but I was beyond frustrated with spending 6 hours today on this when I have other finals, a project, and a thesis all to wrap up by next week. I can tell you I won't be shedding a tear when this class is in my rearview mirror, that's for sure!

You have been so helpful, thank you for your patience and explanations!
Have a great night and weekend!
- Rebecca
Re: JPEG image help - Easy for people who understand IDL?! [message #82389 is a reply to message #82299] Thu, 06 December 2012 15:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> Secondly, the oceans.jpg says in the regular file explorer of my
computer that it's 367x137 jpg file, same deal with Sky, which is how I
got those dimensions.
>
> For "rebin", I thought it would be good if the less-wide image, sky, could be the same width as ocean. I added the line
>
> sky2=rebin(sky,367,137)
>
> and then changed the later instance of "sky" to "sky2".
>
> Of course I got execution halted, (Rebin: Result dimensions must be integer factor of original dimensions). I spent an hour trying to read about Rebin, decided I don't understand and cannot seem to translate it into this homework, and tried other things.

Well, "integer" means a counting number: 1, 2, 3, etc. So, if the thing
you are trying to change the size of is, say, 20 units, then Rebin will
allow you to change its size to 40, or 60 or 80 units, but not to 367
or 137 units. :-)

If you want to change the size to some arbitrary unit, you have
to use Congrid, not Rebin.

> I really am doomed! I'm a senior in college and all of my grades over the years have been A's and A-'s, but I am taking this single course pass/fail and think I will be failing. I appreciate all of your advice, by the way, thank you immensely for your tips. :)

Well, I'm not sure about doomed. I don't think I would
be counting on an A, though, to be honest. Maybe computers
are not your thing. I'll bet you would be a terrific
Jungian psychologist! What is your major?

Look, if it gets desperate, I'll give you the three
line answer. It will probably impress the prof so much
he'll give you the P. ;-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82390 is a reply to message #82299] Thu, 06 December 2012 15:45 Go to previous message
Rebecca C is currently offline  Rebecca C
Messages: 5
Registered: December 2012
Junior Member
Haha, well I got those numbers by just viewing it with the TV and trying out different things until both showed up in full without being cut off, so its just approximate and admittedly random.

Secondly, the oceans.jpg says in the regular file explorer of my computer that it's 367x137 jpg file, same deal with Sky, which is how I got those dimensions.

For "rebin", I thought it would be good if the less-wide image, sky, could be the same width as ocean. I added the line

sky2=rebin(sky,367,137)

and then changed the later instance of "sky" to "sky2".

Of course I got execution halted, (Rebin: Result dimensions must be integer factor of original dimensions). I spent an hour trying to read about Rebin, decided I don't understand and cannot seem to translate it into this homework, and tried other things.

I really am doomed! I'm a senior in college and all of my grades over the years have been A's and A-'s, but I am taking this single course pass/fail and think I will be failing. I appreciate all of your advice, by the way, thank you immensely for your tips. :)

Rebecca
Re: JPEG image help - Easy for people who understand IDL?! [message #82391 is a reply to message #82299] Thu, 06 December 2012 15:42 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> Three commands is all it would take?! Wow, I'm really doing this wrong! And unfortuanately this is the *end* of the semester, so we should be winding down now.

Really!? The *end* of the semester. Wow.

OK, at least we know where the professor is now. He's
downtown at the local pub about 10 drinks into it by now. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82392 is a reply to message #82299] Thu, 06 December 2012 15:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> Any suggestions on what I'm missing?

How did you try to rebin your image? What errors did you get?
Is Ocean *really* only a 367x137 array? How could you tell?
(Hint, you need HELP.)

Where in the world do the numbers 385 and 333 come from!?
Please put the Owiji board away!

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82393 is a reply to message #82299] Thu, 06 December 2012 15:24 Go to previous message
Rebecca C is currently offline  Rebecca C
Messages: 5
Registered: December 2012
Junior Member
Three commands is all it would take?! Wow, I'm really doing this wrong! And unfortuanately this is the *end* of the semester, so we should be winding down now.

Our lesson on jpeg files was one slide long, and told us "read_JPEG" was the thing to do, and that we could figure everything else out ourselves based on array manipulation, which is what I learned last week! Anyway, making up and googling possible commands and guessing how to place brackets for the right results is not working out too well for me.

I think that both images are well-contained with a bit of extra space in a 385x333 window.

Ocean is 367 x 137, and Sky is 259 x 194. I thought I would try to "rebin" one of them so they match array sized, but I only reached errors.


Additionally, here's the homework assignment:

There are two picture files attached with this email, merge the two into one, with the sky on top while the ocean on bottom. But please keep the top and bottom portions the same size and show as many clouds as you can in your final picture.

Save your picture following these steps:

1. Set a window matching your picture size (assuming a name as xyz)
2. tv, xyz, true=1
3. write_jpeg, 'your filename', tvrd(/true), /true


which is why I thought to use TV in the first place.
I can't seem to find any good explanations of how to move around the arrays of JPG's or show one on top of the other, so I guess I'm resorting to workarounds like changing the window size and hoping for the best. Anything I try to do that worked for text and integer arrays, doesn't seem applicable now.
Any suggestions on what I'm missing?
Thanks again!!
- Rebecca
Re: JPEG image help - Easy for people who understand IDL?! [message #82394 is a reply to message #82299] Thu, 06 December 2012 15:14 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> In the second lesson, he will introduce them to the
> Coyote Library, and all will be well, This assignment,
> for example, can be done in four simple commands! ;-)

Well, three, actually. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82395 is a reply to message #82299] Thu, 06 December 2012 15:07 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

>
> David, thank you so much for your reply! I actually do have the Ken Bowman book, but I find it too complex to understand (I was mistakenly placed into this class, but due to financial aid/registration reasons could not leave, and must pass it to graduate. I have no programming background or intention of ever being near IDL again in my life, after I make it through this class!)
>
> Anyway, after browsing this document - http://www.astro.cornell.edu/academics/courses/astro310/IDL_ Image_Tutorial.pdf - I modified what I wrote so far, which by trial and error, adjusting the window size, I can make look like what it's supposed to look like.
>
> However, I can't understand what each part means. Let me pose one specific question: I noticed that when I change the value next to "tv, ocean", the picture of the ocean moves up and down. But, only whole numbers make a difference, and I can only see it in the lower positions if I happen to make the window large enough (via guessing).
>
> Could you tell me what that parameter is that I am changing? I'll be setting it to "2", and trial-and-error'ing the window size to squish the ocean image right up under the sky image, and calling it a day. But, I'd like to understand what the number's for!
>
> Thanks again! Here is the "new" .pro:
>
> PRO jpghomework2
> file='sky.jpg'
> read_JPEG,file,sky
>
> file2='ocean.jpg'
> read_JPEG,file2,ocean
>
>
> window,xsize=[400],ysize=[650],title="combined"
>
> tv,sky,0,true=1
> tv,ocean,2,true=1 ;<<< This number 2 is the one I'm wondering about
>
> end
>
>
> Thanks again a million!!
> - Rebecca

Humm. Yes, what you are changing is the "position" of the
image in the window. Unfortunately, image "positions" are
pretty hard to understand, and are calculated using a
complicated formula that considers the size of the image
AND the size of the window. You might be better off looking
at the parameters X and Y, rather than the Position. Those
will be easier for you to understand, I think.

What sizes are your images? How big a window do you need
to display the two images, do you think?

You don't need those brackets around your window sizes,
by the way. You can write the command like this:

window,xsize=400,ysize=650,title="combined"

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82396 is a reply to message #82299] Thu, 06 December 2012 14:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> Our professor is nonexistent (unreachable, no course material etc) so please think of this as I'm just a person who knows nothing about IDL, has Google, and the IDL workstation in front of me to try things out.

At first I thought this professor was a cold, heartless
bastard for making his students do an assignment with
the TV command, for God's sake. Then, I realized the
genius of his method. This assignment isn't SUPPOSE to be
completed! It is just to show his student's how pointless
it is to use these old IDL commands.

In the second lesson, he will introduce them to the
Coyote Library, and all will be well, This assignment,
for example, can be done in four simple commands! ;-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: JPEG image help - Easy for people who understand IDL?! [message #82397 is a reply to message #82299] Thu, 06 December 2012 14:57 Go to previous message
Rebecca C is currently offline  Rebecca C
Messages: 5
Registered: December 2012
Junior Member
David, thank you so much for your reply! I actually do have the Ken Bowman book, but I find it too complex to understand (I was mistakenly placed into this class, but due to financial aid/registration reasons could not leave, and must pass it to graduate. I have no programming background or intention of ever being near IDL again in my life, after I make it through this class!)

Anyway, after browsing this document - http://www.astro.cornell.edu/academics/courses/astro310/IDL_ Image_Tutorial.pdf - I modified what I wrote so far, which by trial and error, adjusting the window size, I can make look like what it's supposed to look like.

However, I can't understand what each part means. Let me pose one specific question: I noticed that when I change the value next to "tv, ocean", the picture of the ocean moves up and down. But, only whole numbers make a difference, and I can only see it in the lower positions if I happen to make the window large enough (via guessing).

Could you tell me what that parameter is that I am changing? I'll be setting it to "2", and trial-and-error'ing the window size to squish the ocean image right up under the sky image, and calling it a day. But, I'd like to understand what the number's for!

Thanks again! Here is the "new" .pro:

PRO jpghomework2
file='sky.jpg'
read_JPEG,file,sky

file2='ocean.jpg'
read_JPEG,file2,ocean


window,xsize=[400],ysize=[650],title="combined"

tv,sky,0,true=1
tv,ocean,2,true=1 ;<<< This number 2 is the one I'm wondering about

end


Thanks again a million!!
- Rebecca
Re: JPEG image help - Easy for people who understand IDL?! [message #82398 is a reply to message #82299] Thu, 06 December 2012 14:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rebecca C writes:

> I'm not really sure what this group is for but I'm hoping someone who understands IDL can see this and help me! Thanks in advance for reading on :)

You are in the right place to learn something about IDL,
but we don't do homework here. (Most of us have had our
fill of it in previous lives.)

> So, I'm in "Intro to IDL" class, and understand mostly nothing.

Oh, oh. There are some pretty good books available. You might
want to see if you can find one in the library. I would
recommend Ken Bowman's book as a really good place to start:

http://www.idlcoyote.com/documents/book_recommendations.html


> We are given two files, one "ocean.jpg" and the other "sky.jpg". The question is to merge the two jpegs so one is on top, and the other on bottom, and to save this jpg.
>
> Here is the procedure I have:
>
> PRO jpghomework
>
> file='sky.jpg'
> read_JPEG,file,sky
>
> file2='ocean.jpg'
> read_JPEG,file2,ocean
>
> tv,sky,true=1
> tv,ocean,true=1
>
> end
>
> I have been trying to read and figure this out for two days, and it is due soon. Our professor is nonexistent (unreachable, no course material etc) so please think of this as I'm just a person who knows nothing about IDL, has Google, and the IDL workstation in front of me to try things out.

Well, maybe you will get a C for effort, anyway. Here is what I
do. I would open up the IDL on-line help:

IDL> ?

And I would study the keywords for the Window, Size,
and TVRD commands, and, of course, the TV command. Do
this for 10-15 minutes and see if a specific question
occurs to you. If it does, get back to us and we'll see
how it goes. We are very good at answering specific
questions. :-)

Most of your questions, by the way, can be found by
perusing this web page:

http://www.idlcoyote.com

Especially, the Programming Tips section:

http://www.idlcoyote.com/documents/tips.php

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Two new IDL Help Articles describing how to use the Workbench are made available now.
Next Topic: Obtaining all values of an HDF5 attribute w/o looping

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

Current Time: Wed Oct 08 15:16:02 PDT 2025

Total time taken to generate the page: 0.00662 seconds