Low-Cost Computational Astrophotography
Total Page:16
File Type:pdf, Size:1020Kb
Low-cost Computational Astrophotography Joseph Yen Peter Bryan Electrical Engineering Electrical Engineering Stanford University Stanford University [email protected] [email protected] Abstract 2. Related Work When taking photographs of the night sky, long ex- Currently, most astrophotographers compensate for posure times help photographers observe many stars, the rotation of the earth by physically moving the cam- but the rotation of the earth results in long star streak era along with the earth. However, some attempts arcs about the celestial pole. An algorithm for re- have been made to remove this requirement. To accu- moving these star streaks and substituting accurately rately localize stars in streaked images, one researcher placed point-like stars is designed and implemented. has re-mapped the star streak to polar coordinates, so Images containing star streaks are transformed into that all stars will have the same point-spread function. ones with un-streaked starry skies while retaining This technique was designed for locating specific stars color and brightness information. The procedure is for the purpose of identifying specific stars, but will shown to work consistently on a 35-image dataset. be applicable for our purposes when removing star streaks [4]. Other factors besides streaking can cause quality degradation in star images, and attempts have 1. Introduction been made to correct this. These have used such tech- niques as Richardson-Lucy deblurring [2] and maxi- Astrophotography is a widespread pastime in which mally sparse optimization [1]. DSLR cameras are used to take images of objects in space. Certain factors make this a very expen- sive hobby. One of these is the rotation of the earth. 3. Data Collection Very long exposure times are required to capture pho- tos of faint celestial bodies, and the earths rotation Initially, we intended to produce our own images causes these objects to move in the sky during the ex- of starry skies by taking photos of the night sky at posure. This causes the formation of ”star streaks,” Stanford. However, due to unfortunately cloudy and bright lines in the photograph tracing out stars’ trajec- rainy weather, we were unable to take acceptable pho- tory across the sky. These streaks can be aesthetically tos that could be post-processed. Instead, we collected pleasing and many photographers deliberately create a data set of 35 photos of star streaks gathered from streaked images. However, in producing an accurate the internet, via a Google Image search. To ensure image of the sky, they are detrimental. To compen- that our procedure would be able to handle the images, sate for this motion, astrophotographers use moving we selected images in which the celestial pole was camera and telescope mounts to keep objects steady in within the photograph. The images also had varied the frame. These mounts can cost thousands of dol- parameters such as foreground/background elements, lars, making astrophotography prohibitively expensive amount of star streaks, illumination, and noise. Any for most people. We hope to use computational tech- watermarks and borders left in the photographs were niques to remove the need for these rotating mounts cropped out to avoid the possibility that they could be and instead post-process these long-exposure images. segmented as stars. 1 Figure 1. Image processing pipeline 4. Image Segmentation In order to effectively convert the star streaks into Figure 2. Different thresholding methods points, image segmentation is needed to separate out the streaks, as detailed in Figure 1. The star streaks method calculates an optimal threshold such that the could be of varying brightness and color, even along a intra-class variance is at its maximum while the inter- single streak. In addition, even though the majority of class variance is at its minimum. The stars are then the sky is relatively dark at night, there could still be segmented based on this calculated threshold and re- some color and brightness gradients in different parts moved from the image. Again, to minimize the amount of the sky as well. Finally, there will often be objects of dark patches, we iterate through the image again and in the foreground that will need to be separated from replace the removed pixels with their original values if the remaining star streaks in the background. too much information was removed in a given region. Finally, we perform thresholding by looking at the 4.1. Thresholding HSV values converted from the RGB image. Convert- We perform three types of thresholding to segment ing the image to HSV representation allows us to look the star streaks from the rest of the image. Each at the hue, saturation, and value separately unlike in method is performed independently before combining the RGB space. This will help us to catch some of to minimize the chance for unwanted segmentations to the more faded streaks in the image. After convert- be compounded forward, as shown in Figure 2. ing the the HSV space, we look at the value array and First, we use global thresholding by looking at the only segment out the pixels that have a higher value in grayscale versions of the original images. If the pixel comparison to a modified mean. Similar to the previ- value on the black and white image is greater than a ous thresholding methods, we post-process the result- global threshold, we consider it part of a star streak in ing image to remove the dark spots. the color image. This will allow us to catch the bright- 4.2. Width Estimation est star streaks, while retaining the color information. However, this could cause large patches of images to To take into account the individual star streaks be considered as stars and removed from the image if could be varying in brightness and color along its path, their grayscale values are too high. To address this, we we also include the neighboring pixels that are within a perform a second iteration through the image and refill certain gradient from the pixels that were removed by the pixels with their original values if the proportion the thresholding methods. This will allow us to cap- of information in a given window that was removed ture a more representative portion of the star streak exceeded a certain percentage, as shown in Figure 3. while leaving less behind, as even though the bright- We then use Otsu’s method as a clustering-based ness tends to be highest in the center of the streak, image thresholding technique to effectively separate dimmer portions along the width of the star are also the background of the image from the foreground part of the streak. This method also helps account for while segmenting a different set of star streaks [3]. varying streak widths, in comparison to just using a Using a binary version of the original image, Otsu’s defined region size of neighbors, as shown in Figure 4. 2 Figure 3. Patch removal: before vs. after Figure 5. Polar transform vs compressed clusters around the celestial north pole, as shown in Figure 5. Because of this, there is not a uniform ”point spread function” applied to the stars in Cartesian coordinates Figure 4. Width estimation that could be used to perform deconvolution. We trans- form the star streak image into polar coordinates with the origin at the celestial pole to have each individual 4.3. Combining Methods streak appear as an approximately horizontal line of a After performing the three independent threshold- uniform length [1]. ing methods and accurately estimating the star widths, A few possibilities exist to identify the star’s axis of we combine the resulting star streaks in order to max- rotation. An algorithm is used to automatically locate imize the number of streaks we remove from the im- the coordinates of the axis, even if the axis lay outside age segmentation. As an extra check, we look at the the image [1]. We chose to instead test our procedure amount of information that had been taken out of the exclusively on images in which the celestial pole lay original image before combining the results. As cer- within the image, and to have the user manually in- tain methods would work better than others on images dicate the location of the axis by clicking on it when with varying parameters such as illumination and qual- prompted. ity, we only combine the ones that removed a balanced 5.2. Star Clustering amount of pixel values so that we do not lose too much information in comparison with the original image, as After transforming the streaks into polar coordi- shown in Figure 2. nates, we were able to convert them into points. Ini- We also experimented with other segmentation tially, deconvolution based on a uniform point-spread techniques such as edge detection, but the results were function was attempted. However, the star streaks in even worse than those of global thresholding. This the images tested did not form uniform circles, and so may be because the star streaks are so densely packed did not form perfectly uniform lines in polar coordi- in the data images. Other problems included many nates. Deconvolution, then, was not an effective strat- artifacts along the foreground/background boundaries, egy. Instead, a recursive clustering algorithm was im- especially along the horizon. As such, we balanced plemented. In this algorithm, a bright pixel was iden- multiple thresholding methods instead, which gave tified, and its neighbors were added to a cluster if they significantly better results. were not surrounded entirely by dark pixels. This pro- cess was repeated until the complete cluster had been 5. Star Streak Modification formed. The cluster (i.e. an individual streak) was then compressed into a single pixel, by averaging the val- 5.1.