Commit eaa7c563 authored by Jan Eichler's avatar Jan Eichler
Browse files

important debug: correct projection onto the lower hemisphere.

main changes in functions:
import_data() - changing sign before 3rd component of tiny_vector
calculate_grains() - turn vectors down and negative z in the calculation of colatitude
other changes:
writing needless files (broken links to hdf5 files) disabled for the slim version
parent aca1517b
......@@ -301,7 +301,7 @@ int import_data_g60AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image2(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -312,7 +312,7 @@ int import_data_g60AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image2(x, y) = tiny_vector;
}
......@@ -327,7 +327,7 @@ int import_data_g60AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -338,7 +338,7 @@ int import_data_g60AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image(x, y) = tiny_vector;
}
......@@ -474,7 +474,7 @@ int import_data_g50AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image2(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -485,7 +485,7 @@ int import_data_g50AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image2(x, y) = tiny_vector;
}
......@@ -500,7 +500,7 @@ int import_data_g50AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -511,7 +511,7 @@ int import_data_g50AWI()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image(x, y) = tiny_vector;
}
......@@ -649,7 +649,7 @@ int import_data_g60Mainz()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image2(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -660,7 +660,7 @@ int import_data_g60Mainz()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image2(x, y) = tiny_vector;
}
......@@ -675,7 +675,7 @@ int import_data_g60Mainz()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -686,7 +686,7 @@ int import_data_g60Mainz()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image(x, y) = tiny_vector;
}
......@@ -785,7 +785,7 @@ int import_data_g50LGGE()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image2(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -796,7 +796,7 @@ int import_data_g50LGGE()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image2(x, y) = tiny_vector;
}
......@@ -814,7 +814,7 @@ int import_data_g50LGGE()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[2]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //z
tiny_vector[1]=-cos(co_image(x,y)*M_PI/180); //y
tiny_vector[1]=cos(co_image(x,y)*M_PI/180); //y
vector_image(x, y) = tiny_vector;
}
else //horizontal thin section
......@@ -825,7 +825,7 @@ int import_data_g50LGGE()
//x->east, y->north, z->up
tiny_vector[0]=sin(co_image(x,y)*M_PI/180)*cos(az_image(x,y)*M_PI/180); //x
tiny_vector[1]=sin(co_image(x,y)*M_PI/180)*sin(az_image(x,y)*M_PI/180); //y
tiny_vector[2]=cos(co_image(x,y)*M_PI/180); //z
tiny_vector[2]=-cos(co_image(x,y)*M_PI/180); //z
vector_image(x, y) = tiny_vector;
}
......@@ -967,6 +967,24 @@ int rotate_topo_image(vigra::FImage &image)
return 0;
}
int export_topo_image(vigra::FImage topo_image, std::string path)
{
float max_value;
max_value = maximal_misorientation;
vigra::FImage new_image(mWidth, mHeight);
for (int y=0; y<mHeight; y++)
for (int x=0; x<mWidth; x++)
{
if(topo_image(x,y)>maximal_misorientation)
new_image(x,y) = maximal_misorientation;
else new_image(x,y) = topo_image(x,y);
}
exportImage(srcImageRange(new_image), vigra::ImageExportInfo(path.c_str()));
return 0;
}
int export_grains_bw(vigra::IImage grain_label_image, std::string path)
{
vigra::IImage grain_image(mWidth,mHeight);
......@@ -1581,8 +1599,8 @@ int calculate_grains(vigra::IImage &grain_label_image, vigra::FVector3Image &vec
std::cout << ".";
for(int i=1; i<=nr_grains; i++)
{
if (Grain[i].axis[2]<0.0)
Grain[i].axis=-Grain[i].axis; //rotate all grain axis vectors in positiv z-direction ("up")
if (Grain[i].axis[2]>0.0)
Grain[i].axis=-Grain[i].axis; //rotate all grain axis vectors in negative z-direction ("down") - projection onto the lower hemisphere
if (Grain[i].axis[1]>0.0 && Grain[i].axis[0]>=0.0)
Grain[i].az=atan(Grain[i].axis[0]/Grain[i].axis[1])*180/M_PI;
else if (Grain[i].axis[1]<0.0)
......@@ -1592,7 +1610,7 @@ int calculate_grains(vigra::IImage &grain_label_image, vigra::FVector3Image &vec
else if (Grain[i].axis[0]>0.0) Grain[i].az=90;
else if (Grain[i].axis[0]<0.0) Grain[i].az=270;
else Grain[i].az=0;
Grain[i].co=acos(Grain[i].axis[2]/sqrt(vigra::squaredNorm(Grain[i].axis)))*180/M_PI;
Grain[i].co=acos(-Grain[i].axis[2]/sqrt(vigra::squaredNorm(Grain[i].axis)))*180/M_PI; //acos(-z) because lower hemisphere projection
}
std::cout << " done" << std::endl;
......
......@@ -2,7 +2,7 @@
#include "misorient.cpp"
#include <unistd.h>
std::string cAxes_version = "18.3.1 slim";
std::string cAxes_version = "19.10.8 slim";
//functions
int analysis();
......@@ -12,7 +12,7 @@ int main(int argc, char ** argv)
if (argc==1) //command line modus
{
//hello
std::cout << "cAxes is a program for FA data processing. \n";
std::cout << "cAxes is a program for the processing of Fabric Analyser data. \n";
std::cout << "Version: " << cAxes_version << "\n\n";
//input parameters
......@@ -185,7 +185,8 @@ int analysis()
std::string filepath_boundaries_txt = new_directory+"/boundaries.txt";
std::string filepath_stereo = new_directory+"/stereo.txt";
std::string filepath_xstereo = new_directory+"/xstereo.txt";
std::string filepath_quality = new_directory+"/quality.png";
std::string filepath_quality = new_directory+"/quality.png";
std::string filepath_topo_image = new_directory+"/topo_image.png";
/*********************************************************/
......@@ -276,6 +277,7 @@ int analysis()
exportImage(srcImageRange(gq_image), vigra::ImageExportInfo("gq.bmp"));
exportImage(srcImageRange(quality_image), vigra::ImageExportInfo("quality.bmp"));
*/
vigra::BasicImage<bool> topo_binary_image(mWidth,mHeight);
......@@ -453,7 +455,8 @@ int analysis()
compute_and_save_cgp_data_structure(filepath_cgp.c_str(),1,0);
//Create symbolic links
//Create symbolic links disabled in slim-version
/*
std::string image_id_str = sourcepath;
int lastInstanceOfSlash = image_id_str.find_last_of("/"); //Get the last slash before the image's id
image_id_str = image_id_str.substr(lastInstanceOfSlash + 1, image_id_str.length()); //The image number is inbetween
......@@ -465,7 +468,7 @@ int analysis()
symlink(filepath_h5file.c_str(), h5file_out.c_str());
symlink(filepath_objects.c_str(), objects_out.c_str());
symlink(filepath_regions.c_str(), bmp_out.c_str());
*/
/****************************************************************************/
/* Create grain and boundary data structure and calculate c-axis statistics */
......@@ -501,6 +504,9 @@ int analysis()
//export boundaries in color
export_boundary_rgb(boundary_label_image, regions, bground_image, Grain, Boundary, filepath_boundary_rgb); std::cout << ".";
//export subgrain misorientation topography (testing)
//export_topo_image(topo_image, filepath_topo_image); std::cout << ".";
std::cout << " done" << std::endl;
/**************************************/
......@@ -519,7 +525,7 @@ int analysis()
write_grains_txt(Grain, filepath_grains_txt); std::cout << ".";
//2nd version containing even axis values
write_grains_txt2(Grain, filepath_grains2_txt); std::cout << ".";
// write_grains_txt2(Grain, filepath_grains2_txt); std::cout << "."; // disabled in slim-version
write_stereo_txt(Grain, filepath_stereo); std::cout << ".";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment