Converted image data arrays rawData,red,green,blue to array2D class objects.

This commit is contained in:
Emil Martinec
2012-04-03 01:09:29 -05:00
parent b9b6d7aed9
commit 91dc09b0ee
4 changed files with 27 additions and 52 deletions

View File

@@ -823,22 +823,19 @@ void RawImageSource::ppg_demosaic()
if(plistener) plistener->setProgress(0.67 + 0.33*row/(height-1));
}
red = new float*[H];
for (int i=0; i<H; i++) {
red[i] = new float[W];
for (int j=0; j<W; j++)
red(W,H);
for (int i=0; i<H; i++)
for (int j=0; j<W; j++) {
red[i][j] = image[i*W+j][0];
}
green = new float*[H];
for (int i=0; i<H; i++) {
green[i] = new float[W];
for (int j=0; j<W; j++)
green(W,H);
for (int i=0; i<H; i++)
for (int j=0; j<W; j++) {
green[i][j] = image[i*W+j][1];
}
blue = new float*[H];
for (int i=0; i<H; i++) {
blue[i] = new float[W];
for (int j=0; j<W; j++)
blue(W,H);
for (int i=0; i<H; i++)
for (int j=0; j<W; j++) {
blue[i][j] = image[i*W+j][2];
}
free (image);
@@ -1058,21 +1055,15 @@ void RawImageSource::ahd_demosaic(int winx, int winy, int winw, int winh)
void RawImageSource::nodemosaic()
{
red = new float*[H];
green = new float*[H];
blue = new float*[H];
red(W,H);
green(W,H);
blue(W,H);
for (int i=0; i<H; i++) {
red[i] = new float[W];
green[i] = new float[W];
blue[i] = new float[W];
for (int j=0; j<W; j++){
switch( FC(i,j)){
case 0: red[i][j] = rawData[i][j]; green[i][j]=blue[i][j]=0; break;
case 1: green[i][j] = rawData[i][j]; red[i][j]=blue[i][j]=0; break;
case 2: blue[i][j] = rawData[i][j]; red[i][j]=green[i][j]=0; break;
//red[i][j] = rawData[i][j];
//green[i][j] = rawData[i][j];
//blue[i][j] = rawData[i][j];
}
}
}

View File

@@ -40,7 +40,8 @@ void RawImageSource::green_equilibrate(float thresh)
int height=H, width=W;
// local variables
array2D<float> cfa (width,height,rawData);
float** rawptr = rawData;
array2D<float> cfa (width,height,rawptr);
//array2D<int> checker (width,height,ARRAY2D_CLEAR_DATA);

View File

@@ -77,12 +77,8 @@ PIX_SORT(p[1],p[2]) ; median=p[2] ;}
RawImageSource::RawImageSource ()
:ImageSource()
,plistener(NULL)
,green(NULL)
,red(NULL)
,blue(NULL)
,cache(NULL)
,border(4)
,rawData(NULL)
,ri(NULL)
{
hrmap[0] = NULL;
@@ -104,15 +100,6 @@ RawImageSource::~RawImageSource () {
delete ri;
}
//These freeArray commands are causing RT not to terminate properly ???
/*if (green)
freeArray<float>(green, H);
if (red)
freeArray<float>(red, H);
if (blue)
freeArray<float>(blue, H);
if(rawData)
freeArray<float>(rawData, H);*/
if( cache )
delete [] cache;
if (hrmap[0]!=NULL) {
@@ -945,9 +932,9 @@ int RawImageSource::load (Glib::ustring fname, bool batch) {
rml.ciffLength = ri->get_ciffLen();
idata = new ImageData (fname, &rml);
green = allocArray<float>(W,H);
red = allocArray<float>(W,H);
blue = allocArray<float>(W,H);
green(W,H);// = allocArray<float>(W,H);
red(W,H);// = allocArray<float>(W,H);
blue(W,H);// = allocArray<float>(W,H);
//hpmap = allocArray<char>(W, H);
if (plistener) {
@@ -1148,23 +1135,19 @@ void RawImageSource::flushRawData() {
cache = 0;
}
if (rawData) {
freeArray<float>(rawData, H);
rawData = 0;
rawData(0,0);
}
}
void RawImageSource::flushRGB() {
if (green) {
freeArray<float>(green, H);
green = 0;
green(0,0);
}
if (red) {
freeArray<float>(red, H);
red = 0;
red(0,0);
}
if (blue) {
freeArray<float>(blue, H);
blue = 0;
blue(0,0);
}
}
@@ -1191,7 +1174,7 @@ void RawImageSource::copyOriginalPixels(const RAWParams &raw, RawImage *src, Raw
{
if (ri->isBayer()) {
if (!rawData)
rawData = allocArray<float>(W,H);
rawData(W,H);
if (riDark && W == riDark->get_width() && H == riDark->get_height()) {
for (int row = 0; row < H; row++) {
for (int col = 0; col < W; col++) {
@@ -1276,7 +1259,7 @@ void RawImageSource::copyOriginalPixels(const RAWParams &raw, RawImage *src, Raw
} else {
// No bayer pattern
// TODO: Is there a flat field correction possible?
if (!rawData) rawData = allocArray<float>(3*W,H);
if (!rawData) rawData(3*W,H);
if (riDark && W == riDark->get_width() && H == riDark->get_height()) {
for (int row = 0; row < H; row++) {

View File

@@ -100,14 +100,14 @@ class RawImageSource : public ImageSource {
double* cache;
int threshold;
float** rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
array2D<float> rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
// the interpolated green plane:
float** green;
array2D<float> green;
// the interpolated red plane:
float** red;
array2D<float> red;
// the interpolated blue plane:
float** blue;
array2D<float> blue;
void hphd_vertical (float** hpmap, int col_from, int col_to);