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

Home » Public Forums » archive » Re: making a circle of certain values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: making a circle of certain values [message #56130 is a reply to message #56126] Mon, 01 October 2007 13:21 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
rpertaub@gmail.com wrote:
> Hi,
> I have a set of data points (x,y coordinates) that can be plotted on
> my 1240,1024 array. However, they are sparse x,y spots across the
> image, and I want to 'thicken' it by drawing a circle with my x,y as
> centers. I want to give it a certain radius and a certain value too,
> so that the pixels in the circle (the filling) have values and can
> thus contribute to my rgb image...
> anyone know how to draw a circle, and assign a value to pixels within
> that circle?
>
> Thanks!
> RP
>

Hi,

I am not sure if you want to display the circle or not. If not, you can
compute the distances from your pixel to every other pixels, then select
only the cells that are close enough. Here is a code I wrote a long time
ago (might not be the most optimized one, but it works well!)

So, you have an image of 100*200:
distances = distanceInMatrix(image, PointX,PointY, 100)
circle = where(distances le radius)
image[circle] = newValue

Jean.


;This function compute for every point in the array the distance to the
origine point.
;INPUT: indexCells: a 1D or 2D array of coordinate, for which the
;distances will be computed.
; xPos and yPos: the position of the origine point
; x_size: the size of the matrix (number of columns)
;OUTPUT: a float array of distances to the origine point
;
;Author: Jean-Gabriel Hasbani
; jghasban@DELETETHIS.ucalgary.ANDTHIS.ca
; September 2005

function distanceInMatrix, indexCells, xPos,yPos, x_size
;print, "the index", indexCells
numberOfDistances = N_elements(indexCells)

;get the X;Y coordinate of the points.
coordCells = ulonarr(2,numberOfDistances)
coordCells[1,*] = indexCells[*] / x_size ;Y
coordCells[0,*] = indexCells[*] - x_size * coordCells[1,*] ;X


distances = fltarr(numberOfDistances)
distances[*] = sqrt((xPos*1.0 - coordCells[0,*]*1.0)^2+(yPos*1.0-
coordCells[1,*]*1.0)^2)

;print, coordCells
;print, "In the distance Matrix:", distances
return, distances
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SetPixelData Error
Next Topic: label x axis

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

Current Time: Sat Oct 11 14:38:54 PDT 2025

Total time taken to generate the page: 1.04056 seconds