I am working with a square .fits image which displays a circular image fitted inside. I want to iterate through each pixel in this image and print the "bad" pixels onto a text file generated by the code. "Bad" pixels are ones which fall in the edges outside of the circle. As of now, my problem lies in actually calling up the image and reading pixels from it. Since I will need to run this code for a few hundred images, I want to be able to easily summon each image in IRAF and have my code print out the "bad" pixel coordinates.
Here is what I have so far:
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main() {
// Open the file in write mode.
ofstream outputFile;
outputFile.open ("CCDmask.txt");
// Set dimensions and important point locations.
int xDimension = 1481;
int yDimension = 1469;
double xCenter = ;
double yCenter = ;
double xCircum = 60;
double yCircum = 1000;
// Calculate radius of image.
double radius = sqrt( pow(xCircum-xCenter,2) + pow(yCircum-yCenter,2) );
// Iterate through pixels.
for (int x = 1; x <= xDimension; x++) {
for (int y = 1; y <= yDimension; y++) {
// Calculate distance between each new point and center.
double distance = sqrt( pow(x-xCenter,2) + pow(y-yCenter,2) );
// Print bad pixels.
if (distance > radius) {
outputFile << "(" << x << "," << y << ")" << '\n';
}
}
}
// Close the file.
outputFile.close();
return 0;
}
For reference this is what each image I will edit looks like: starsstarsstars
Though it is necessary to load the image itself, I also need to access the coordinates. I'm not sure how the pixel's coordinates get translated in.