Re: shading/outlining on surface plot [message #82751] |
Fri, 18 January 2013 11:51 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bob Plano writes:
> I suppose I could do something like this with a plots command, but I
> was thinking surface might save me the trouble of having to make
> arrays with all the corner points specified. Thanks, Chris. I read
> your paper on wavelets about once a week because I keep forgetting
> what little I know about them.
I don't think what you are doing is going to work. Here is something
like what you have in mind, I guess. But, the result is not particularly
pleasing to me, although the points on the surface ARE outlined!
;*******************************************************
peak = cgdemodata(2)
dims = Size(peak, /Dimensions)
markedData = Round(Randomu(-5L, 50) * (41*41))
cgLoadCT, 0, /Brewer, /Reverse
markedImage = BytScl(peak)
thisDevice = !D.Name
Set_Plot, 'Z'
Device, Set_Resolution=[dims[0]*5, dims[1]*5], Z_BUFFER=0
cgLoadCT, 0, /Brewer, /Reverse
cgImage, markedImage, XRANGE=[0,dims[0]], YRANGE=[0,dims[1]], NoErase=1
FOR j=0,N_Elements(markedData)-1 DO BEGIN
m = markedData[j]
xy = Array_Indices(dims, m, /DIMENSIONS)
x = xy[0]
y = xy[1]
cgPlotS, [x, x, x+1, x+1, x], [y, y+1, y+1, y, y]
ENDFOR
markedImage = TVRD()
Set_Plot, thisDevice
cgSurface, peak, texture_image=markedimage
END
;*******************************************************
You can see the results here:
http://www.idlcoyote.com/misc/marked_image_2.png
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: shading/outlining on surface plot [message #82753 is a reply to message #82751] |
Fri, 18 January 2013 11:11  |
astroboy.20000
Messages: 39 Registered: August 2012
|
Member |
|
|
On Jan 18, 12:25 pm, David Fanning <n...@idlcoyote.com> wrote:
> Bob Plano writes:
>> I probably didn't pick a very good example of what I'm trying to do,
>> in that the 'pixels' on the surface plot I want to outline are not
>> necessarily contiguous. That is to say, out of a 64 by 64 surface,
>> there might be a few dozen points that need to be highlighted or
>> outlined, at (apparently) random locations. So, contours won't work,
>> at least not in a straightforward way.
>
>> I wonder if it's possible to do something like:
>
>> shade_surf,z,x,y,shades=col, where most of the col array has values
>> that are 'invisible'. I don't suppose there is such a thing...
>
> Actually, something like this works pretty well:
>
> peak = cgdemodata(2)
> markedData = Round(Randomu(-5L, 50) * (41*41))
> cgLoadCT, 0, /Brewer, /Reverse, NColors=254
> markedColor = 'red'
> TVLCT, cgColor('red', /Triple), 255
> markedImage = BytScl(peak, top=254)
> markedImage[markedData] = 255
> cgSurface, peak, texture_image=markedimage
> END
>
> Here is the result:
>
> http://www.idlcoyote.com/misc/marked_image.png
>
> You see one small problem with a very dark green pixels at the very top
> of the data range. I know what causes this and can fix it easily, if you
> think something like this works for you.
>
> 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.")
Thanks Dave,
This is pretty much what I want, except.....
instead of having the selected pixels one particular color, I'd just
like to have them outlined.
What I'm actually doing might be sort of interesting. I have an image
which has colors that correspond to data values. I then create a
colored histogram so to speak: I basically take each pixel and stack
it in the appropriate bin of this histogram I'm making. In the end you
have a mosaic, sort of, where each 'tile' is a pixel from the image. I
can click on one of the tiles, or a pixel of the image, and the
corresponding tile or pixel is outlined. This is a surprisingly useful
tool, especially if you're trying to find out exactly how a
discontiguous set of points falls within a histogram.
What I'd like to do is have the corresponding pixels on a surface plot
also outlined. If all I can do is have them colored a particular
color, that's OK.
I've been trying to do something along the lines of this:
shade_surf,data,xx,yy,/noerase,shades=whatever
xrang=!x.crange
yrang=!y.crange
zrang=!z.crange
for k=0,n_elements(selected_points)-1 do begin
;if k is the index of the point, kk is the index of the next point to
the 'upper right'
kk=some_mapping_procedure(k)
surface, [ [data(k),data(kk)],[data(k),data(kk)] ], [ [x(k),x(kk)],
[x(k),x(kk)]], [ [y(k),y(kk)],[y(k),y(kk)] ],xrange=xrang, $
yrange=yrang, zrange=zrang,shades=some_color
endfor
It's not working well, but I think that's because the
mapping_procedure has a bug. It seems to me that if data, x, and y are
2x2 arrays, with the first and third data elements having the value of
"lower left" and the second and fourth elements having the values of
"upper right", then surface will draw the appropriate box on the pre-
existing surface. I'm not sure if that's how surface works or not.
I'll have to play with it for a bit.
I suppose I could do something like this with a plots command, but I
was thinking surface might save me the trouble of having to make
arrays with all the corner points specified. Thanks, Chris. I read
your paper on wavelets about once a week because I keep forgetting
what little I know about them.
|
|
|
Re: shading/outlining on surface plot [message #82758 is a reply to message #82753] |
Fri, 18 January 2013 09:43  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> You see one small problem with a very dark green pixel at the very top
> of the data range. I know what causes this and can fix it easily, if you
> think something like this works for you.
This problem with one dark pixel seems to have disappeared after a
.Reset. Not sure what was going on there.
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: shading/outlining on surface plot [message #82759 is a reply to message #82758] |
Fri, 18 January 2013 09:25  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bob Plano writes:
> I probably didn't pick a very good example of what I'm trying to do,
> in that the 'pixels' on the surface plot I want to outline are not
> necessarily contiguous. That is to say, out of a 64 by 64 surface,
> there might be a few dozen points that need to be highlighted or
> outlined, at (apparently) random locations. So, contours won't work,
> at least not in a straightforward way.
>
> I wonder if it's possible to do something like:
>
> shade_surf,z,x,y,shades=col, where most of the col array has values
> that are 'invisible'. I don't suppose there is such a thing...
Actually, something like this works pretty well:
peak = cgdemodata(2)
markedData = Round(Randomu(-5L, 50) * (41*41))
cgLoadCT, 0, /Brewer, /Reverse, NColors=254
markedColor = 'red'
TVLCT, cgColor('red', /Triple), 255
markedImage = BytScl(peak, top=254)
markedImage[markedData] = 255
cgSurface, peak, texture_image=markedimage
END
Here is the result:
http://www.idlcoyote.com/misc/marked_image.png
You see one small problem with a very dark green pixels at the very top
of the data range. I know what causes this and can fix it easily, if you
think something like this works for you.
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: shading/outlining on surface plot [message #82762 is a reply to message #82761] |
Fri, 18 January 2013 09:02  |
astroboy.20000
Messages: 39 Registered: August 2012
|
Member |
|
|
Thanks Chris, thanks Dave.
I probably didn't pick a very good example of what I'm trying to do,
in that the 'pixels' on the surface plot I want to outline are not
necessarily contiguous. That is to say, out of a 64 by 64 surface,
there might be a few dozen points that need to be highlighted or
outlined, at (apparently) random locations. So, contours won't work,
at least not in a straightforward way.
I wonder if it's possible to do something like:
shade_surf,z,x,y,shades=col, where most of the col array has values
that are 'invisible'. I don't suppose there is such a thing...
|
|
|
Re: shading/outlining on surface plot [message #82771 is a reply to message #82762] |
Thu, 17 January 2013 21:27  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Thursday, January 17, 2013 11:09:38 AM UTC-7, David Fanning wrote:
> Bob Plano writes:
>
>
>
>> Sorry if this is a dumb question, but....
>
>>
>
>> I'd like to make a surface or shade_surf plot, and outline areas on
>
>> the surface. The basic idea is here:
>
>>
>
>>
>
>>
>
>> make_2d_gaussian,arr,xx,yy ;xx and yy are 2D
>
>> grid point arrays
>
>>
>
>> shade_surf, arr,xx,yy,shades=whatever
>
>>
>
>> keep=where( arr gt .5*max(arr) and arr lt .7*max(arr) )
>
>>
>
>> sub_outline_procedure,arr(keep),xx(keep),yy(keep) ???????????????????
>
>>
>
>>
>
>>
>
>> Is there a relatively easy way to do this?
>
>
>
> No, there are no easy ways to do this, I don't believe, although maybe
>
> this is a case where function graphics can come to the rescue. One
>
> problem is writing on the surface. It is very difficult to know,
>
> unfortunately, where the actual surface *is*, due to round-off errors,
>
> mostly.
>
>
>
> You might try drawing a contour line on top of an image, then using that
>
> to drape over the surface, but I don't expect good results. :-(
>
>
>
> 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.")
Hi Bob,
How about something like the following:
; Sample data, stored in the "elev" variable
RESTORE, FILEPATH('marbells.dat', $
SUBDIRECTORY=['examples', 'data'])
s = SURFACE(elev, COLOR='brown')
; Give two colors so we fill in between the contour level and the top.
c = CONTOUR(elev, C_VALUE=3800, PLANAR=0, /OVERPLOT, /FILL, $
C_COLOR=['white','white'], RGB_TABLE=0)
; Turn off labels, which are on by default.
c = CONTOUR(elev, C_VALUE=3800, PLANAR=0, /OVERPLOT, $
C_COLOR=0, RGB_TABLE=0, C_LABEL_SHOW=0, C_THICK=4)
Cheers,
Chris
ExelisVIS
|
|
|
Re: shading/outlining on surface plot [message #82775 is a reply to message #82771] |
Thu, 17 January 2013 10:09  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bob Plano writes:
> Sorry if this is a dumb question, but....
>
> I'd like to make a surface or shade_surf plot, and outline areas on
> the surface. The basic idea is here:
>
>
>
> make_2d_gaussian,arr,xx,yy ;xx and yy are 2D
> grid point arrays
>
> shade_surf, arr,xx,yy,shades=whatever
>
> keep=where( arr gt .5*max(arr) and arr lt .7*max(arr) )
>
> sub_outline_procedure,arr(keep),xx(keep),yy(keep) ???????????????????
>
>
>
> Is there a relatively easy way to do this?
No, there are no easy ways to do this, I don't believe, although maybe
this is a case where function graphics can come to the rescue. One
problem is writing on the surface. It is very difficult to know,
unfortunately, where the actual surface *is*, due to round-off errors,
mostly.
You might try drawing a contour line on top of an image, then using that
to drape over the surface, but I don't expect good results. :-(
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.")
|
|
|