ltacconi |
04/16/2008 01:21PM (Read 3650 times)
|
|
|
Status: offline
Registered: 04/16/2008
Posts: 10
|
Hello,I have a number of questions regarding the usage of the imfort image pixel axis routine imps2r. I am trying to use it (to no avail) in a routine in the following manner (below is a snippet of test code which illustrates the point):[code:1:c662be2042] ymask = 1.
do 11, ix = 1, 1024
do 12 jy = 1, 1024
buf(ix,jy) = ymask
12 continue
11 continue
call imps2r(iout,buf,1,1024,1,1024,ier)
if (ier .ne. 0) goto 91
[/code:1:c662be2042]
ymask is a declared real variable
ix is a declared integer variable
jy is a declared integer variable
buf is a declared real array of dimensions 1024 x 1024
iout is an image descriptor to the output file with dimensions 1024 x 1024
ier is a declared integer variableCompiling (with fc) and executing this code works (earlier I had a segmentation fault but that turned out to be unrelated).Further, my intent is to "populate" the pixel values of an output image within certain regions with different complex functional forms. While this could at least potentially be done with imexpression I strongly prefer to do it with an imfort routine of my own. In this context:1. Does the "buf" variable above have to have the same dimensionality as represented by the 4 following parameters?
That is, suppose I wanted to write a common value P to all pixels between (x0,y0) and (x1,y1). How could I
achieve this with imps[123]r? I have tried virtually everything and nothing works.2. Related, how do I specify the (x0,y0) to (x1,y1) range in imps2r, as x0,x1,y0,y1 or x0,y0,x1,y1 (where of course
x0,x1,y0,y1 are all integers)? I have tried both without success.Thank you in advance to anyone who can help, and apologies if these are dumb questions,
Lowell Tacconi-Garman
|
|
|
|
fitz |
04/16/2008 01:21PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
[quote:f73ec200eb]Further, my intent is to "populate" the pixel values of an output image within certain regions with different complex functional forms. While this could at least potentially be done with imexpression I strongly prefer to do it with an imfort routine of my own. In this context:[/quote:f73ec200eb]Since your intent is to create complex masks, you might also look as MSKEXPR, MSKREGIONS or TEXT2MASK in the PROTO package.[quote:f73ec200eb]1. Does the "buf" variable above have to have the same dimensionality as represented by the 4 following parameters?
That is, suppose I wanted to write a common value P to all pixels between (x0,y0) and (x1,y1). How could I
achieve this with imps[123]r? I have tried virtually everything and nothing works.[/quote:f73ec200eb]The 'buf' variable just has to be large enough to hold the section you want to write, this can then be placed anywhere in the image even if the image is larger. Attached is a test program to demonstrate. Note that a section such as [100:200,100:200] is actually 101x101 and not 100x100 pixels.As for why you might be having problems: Was the image opened with write permissions (e.g. mode=3 for WRITE_ONLY or mode=2 for READ_WRITE)? Are the pixels you're trying to set all zero or was there some error message?[quote:f73ec200eb]2. Related, how do I specify the (x0,y0) to (x1,y1) range in imps2r, as x0,x1,y0,y1 or x0,y0,x1,y1 (where of course
x0,x1,y0,y1 are all integers)? I have tried both without success. [/quote:f73ec200eb]The arguments are specified as "x0,x1,y0,y1"Cheers,
-Mike[code:1:f73ec200eb]
program imptest character*80 image, errmsg
integer im, ier, axlen(7), naxis, dtype
integer i
real pix(10000)c --- Set dimensions and type (6 is TY_REAL)
image = "test.imh"
axlen(1) = 1024
axlen(2) = 1024
naxis = 2
dtype = 6c --- Create the image.
call imcrea (image, axlen, naxis, dtype, ier)
if (ier .ne. 0) goto 91c --- Open the image for writing, mode '3' is WRITE_ONLY
call imopen (image, 3, im, ier)
if (ier .ne. 0) goto 91c --- Create a pixel mask array 100x100
do 10 i = 1, 10000
pix(i) = 1.0
10 continuec --- Write it to the section at [100:199,200:299]
call imps2r (im, pix, 100, 199, 200, 299, ier)
if (ier .ne. 0) goto 91c --- Close the image and quit.
call imclos (im, ier)
if (ier .ne. 0) goto 91 stopc --- Error exit.
91 call imemsg (ier, errmsg)
write (*, '('' Error: '', a80)') errmsg
stop
end
[/code:1:f73ec200eb]
|
|
|
|
ltacconi |
04/16/2008 01:21PM
|
|
|
Status: offline
Registered: 04/16/2008
Posts: 10
|
Thanks for the very quick reply, and for the clarification.I have a follow-up question (the answer to which I can of course also discover by experimentation if you're too busy!).Suppose that I have an mask which is 100 x 100 pixels, and I want to fill the region [10:19,10:19] with the value 1019. Should I then ensure that the first 100 values of buf (dimensioned to be 10000 elements in length) are 1019, or those "pixels" of buf that correspond to [10:19,10:19] (that is, offset from buf(1))?
|
|
|
|
fitz |
04/16/2008 01:21PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
You need to make sure the first 100 pixels of the buffer are 1019. The routine will effectively write the section line by line but uses the starting address of the buffer you pass in and does the offset in the image itself.-Mike
|
|
|
|
ltacconi |
04/16/2008 01:21PM
|
|
|
Status: offline
Registered: 04/16/2008
Posts: 10
|
Wow! That answer was even faster! Many, many thanks, Mike.
|
|
|
|
| |
|