Skip to content

Commit

Permalink
name changed MeshData -> PixelData
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysg committed May 9, 2018
1 parent df7b336 commit c5b40a1
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 199 deletions.
2 changes: 1 addition & 1 deletion docs/lib_guide/lib_guide.tex
Expand Up @@ -183,7 +183,7 @@ \subsection{Particle Transforms}
apr.particle_intensities.map(apr,absolute_value_of_intensities,[](const uint16_t &a) { return abs(a); });
\end{lstlisting}
\section{Pixel Images and Reconstruction}
Pixel images are handled using the MeshData class and tiff library is used for input-output.
Pixel images are handled using the PixelData class and tiff library is used for input-output.
\subsection{Reconstruction}
Any particle property, stored using ExtraParticleData class, can be interpolated to reconstruct an image, allowing both a piecewise constant and smooth reconstruction. For examples see Example\_reconstruct\_image.
\subsection{Sampling particles from an image}
Expand Down
2 changes: 1 addition & 1 deletion examples/Example_compress_apr.cpp
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char **argv) {
apr.read_apr(options.directory + name + "_compress_apr.h5");
timer.stop_timer();

MeshData<uint16_t> img;
PixelData<uint16_t> img;
apr.interp_img(img,apr.particles_intensities);
std::string output = options.directory + name + "_compress.tif";
TiffUtils::saveMeshAsTiff(output, img);
Expand Down
6 changes: 3 additions & 3 deletions examples/Example_compute_gradient.cpp
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char **argv) {
gradient.map(apr,gradient_magnitude,[](const std::vector<float> &a) { return 20.0f*sqrt(pow(a[0], 2.0f) + pow(a[1], 2.0f) + pow(a[2], 2.0f)); });

// write result to image
MeshData<float> gradient_magnitude_image;
PixelData<float> gradient_magnitude_image;
apr.interp_img(gradient_magnitude_image,gradient_magnitude);
//apr.interp_img(gradient_magnitude_image,apr.particles_intensities);

Expand All @@ -96,9 +96,9 @@ int main(int argc, char **argv) {
if(options.original_image.size() > 0) {

TiffUtils::TiffInfo inputTiff(options.directory + options.original_image);
MeshData<uint16_t> original_image = TiffUtils::getMesh<uint16_t>(inputTiff);
PixelData<uint16_t> original_image = TiffUtils::getMesh<uint16_t>(inputTiff);

std::vector<MeshData<float>> gradient_mesh;
std::vector<PixelData<float>> gradient_mesh;

MeshNumerics::compute_gradient(original_image, gradient_mesh);

Expand Down
8 changes: 4 additions & 4 deletions examples/Example_get_apr.cpp
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char **argv) {

timer.verbose_flag = true;

MeshData<uint16_t> level;
PixelData<uint16_t> level;

apr.interp_depth_ds(level);

Expand Down Expand Up @@ -125,14 +125,14 @@ int main(int argc, char **argv) {
unsigned int blosc_comp_level = options.compress_level;
unsigned int blosc_shuffle = 1;

MeshData<uint16_t> recon_image;
PixelData<uint16_t> recon_image;

apr.interp_img(recon_image, apr.particles_intensities);

TiffUtils::TiffInfo inputTiff(options.directory + options.input);
MeshData<uint16_t> inputImage = TiffUtils::getMesh<uint16_t>(inputTiff);
PixelData<uint16_t> inputImage = TiffUtils::getMesh<uint16_t>(inputTiff);

MeshData<int16_t> diff_image(inputImage.y_num,inputImage.x_num,inputImage.z_num,0);
PixelData<int16_t> diff_image(inputImage.y_num,inputImage.x_num,inputImage.z_num,0);

#ifdef HAVE_OPENMP
#pragma omp parallel for schedule(static)
Expand Down
2 changes: 1 addition & 1 deletion examples/Example_get_apr.h
Expand Up @@ -5,7 +5,7 @@
#include <string>

#include "algorithm/APRParameters.hpp"
#include "data_structures/Mesh/MeshData.hpp"
#include "data_structures/Mesh/PixelData.hpp"
#include "algorithm/APRConverter.hpp"
#include "data_structures/APR/APR.hpp"

Expand Down
6 changes: 3 additions & 3 deletions examples/Example_ray_cast.cpp
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {

apr_raycaster.name = apr.name;

MeshData<uint16_t> views;
PixelData<uint16_t> views;

/////////////
///
Expand All @@ -92,9 +92,9 @@ int main(int argc, char **argv) {
if(options.original_image.size() > 0){

TiffUtils::TiffInfo inputTiff(options.directory + options.original_image);
MeshData<uint16_t> original_image = TiffUtils::getMesh<uint16_t>(inputTiff);
PixelData<uint16_t> original_image = TiffUtils::getMesh<uint16_t>(inputTiff);

MeshData<uint16_t> mesh_views;
PixelData<uint16_t> mesh_views;

apr_raycaster.perpsective_mesh_raycast(original_image,mesh_views);

Expand Down
6 changes: 3 additions & 3 deletions examples/Example_reconstruct_image.cpp
Expand Up @@ -127,7 +127,7 @@ int main(int argc, char **argv) {

if(options.output_pc_recon) {
//create mesh data structure for reconstruction
MeshData<uint16_t> recon_pc;
PixelData<uint16_t> recon_pc;

timer.start_timer("pc interp");
//perform piece-wise constant interpolation
Expand Down Expand Up @@ -179,7 +179,7 @@ int main(int argc, char **argv) {

// Intentionaly block-scoped since local type_recon will be destructed when block ends and release memory.
{
MeshData<uint16_t> type_recon;
PixelData<uint16_t> type_recon;

apr.interp_img(type_recon, type);
TiffUtils::saveMeshAsTiff(options.directory + apr.name + "_type.tif", type_recon);
Expand All @@ -205,7 +205,7 @@ int main(int argc, char **argv) {
if(options.output_smooth_recon) {

//smooth reconstruction - requires float
MeshData<float> recon_smooth;
PixelData<float> recon_smooth;
std::vector<float> scale_d = {2, 2, 2};

timer.start_timer("smooth reconstrution");
Expand Down
6 changes: 3 additions & 3 deletions examples/Example_reconstruct_patch.cpp
Expand Up @@ -191,7 +191,7 @@ int main(int argc, char **argv) {

if(options.output_pc_recon) {
//create mesh data structure for reconstruction
MeshData<uint16_t> recon_pc;
PixelData<uint16_t> recon_pc;



Expand Down Expand Up @@ -245,7 +245,7 @@ int main(int argc, char **argv) {

// Intentionaly block-scoped since local type_recon will be destructed when block ends and release memory.
{
MeshData<uint16_t> type_recon;
PixelData<uint16_t> type_recon;

aprReconstruction.interp_image_patch(apr,type_recon, type,reconPatch);
TiffUtils::saveMeshAsTiff(options.directory + apr.name + "_type.tif", type_recon);
Expand Down Expand Up @@ -291,7 +291,7 @@ int main(int argc, char **argv) {

// Intentionaly block-scoped since local type_recon will be destructed when block ends and release memory.
{
MeshData<uint8_t> type_recon;
PixelData<uint8_t> type_recon;

//level
aprReconstruction.interp_image_patch(apr,type_recon, level,reconPatch);
Expand Down
2 changes: 1 addition & 1 deletion libapr.i
Expand Up @@ -68,7 +68,7 @@ namespace std {
#include "src/numerics/APRNumerics.hpp"
%}

%include "src/data_structures/Mesh/MeshData.hpp"
%include "src/data_structures/Mesh/PixelData.hpp"
%include "src/data_structures/APR/APR.hpp"
%include "src/data_structures/APR/APRIterator.hpp"
%include "src/numerics/APRNumerics.hpp"
Expand Down
42 changes: 21 additions & 21 deletions src/algorithm/APRConverter.hpp
Expand Up @@ -9,7 +9,7 @@
#ifndef PARTPLAY_APR_CONVERTER_HPP
#define PARTPLAY_APR_CONVERTER_HPP

#include "../data_structures/Mesh/MeshData.hpp"
#include "data_structures/Mesh/PixelData.hpp"
#include "../io/TiffUtils.hpp"
#include "../data_structures/APR/APR.hpp"

Expand Down Expand Up @@ -51,30 +51,30 @@ class APRConverter: public LocalIntensityScale, public ComputeGradient, public L
private:
//get apr without setting parameters, and with an already loaded image.
template<typename T>
bool get_apr_method(APR<ImageType> &aAPR, MeshData<T> &input_image);
bool get_apr_method(APR<ImageType> &aAPR, PixelData<T> &input_image);

//pointer to the APR structure so member functions can have access if they need
const APR<ImageType> *apr;

template<typename T>
void init_apr(APR<ImageType>& aAPR, MeshData<T>& input_image);
void init_apr(APR<ImageType>& aAPR, PixelData<T>& input_image);

template<typename T>
void auto_parameters(const MeshData<T> &input_img);
void auto_parameters(const PixelData<T> &input_img);

template<typename T>
bool get_apr_method_from_file(APR<ImageType> &aAPR, const TiffUtils::TiffInfo &aTiffFile);

void get_gradient(MeshData<ImageType> &image_temp, MeshData<ImageType> &grad_temp, MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2, float bspline_offset);
void get_local_intensity_scale(MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2);
void get_local_particle_cell_set(MeshData<ImageType> &grad_temp, MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2);
void get_gradient(PixelData<ImageType> &image_temp, PixelData<ImageType> &grad_temp, PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2, float bspline_offset);
void get_local_intensity_scale(PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2);
void get_local_particle_cell_set(PixelData<ImageType> &grad_temp, PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2);
};

template <typename T>
struct MinMax{T min; T max; };

template <typename T>
MinMax<T> getMinMax(const MeshData<T>& input_image) {
MinMax<T> getMinMax(const PixelData<T>& input_image) {
T minVal = std::numeric_limits<T>::max();
T maxVal = std::numeric_limits<T>::min();

Expand All @@ -96,7 +96,7 @@ MinMax<T> getMinMax(const MeshData<T>& input_image) {
template<typename ImageType> template<typename T>
bool APRConverter<ImageType>::get_apr_method_from_file(APR<ImageType> &aAPR, const TiffUtils::TiffInfo &aTiffFile) {
allocation_timer.start_timer("read tif input image");
MeshData<T> inputImage = TiffUtils::getMesh<T>(aTiffFile);
PixelData<T> inputImage = TiffUtils::getMesh<T>(aTiffFile);
allocation_timer.stop_timer();

method_timer.start_timer("calculate automatic parameters");
Expand Down Expand Up @@ -141,7 +141,7 @@ bool APRConverter<ImageType>::get_apr_method_from_file(APR<ImageType> &aAPR, con
* Main method for constructing the APR from an input image
*/
template<typename ImageType> template<typename T>
bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, MeshData<T>& input_image) {
bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, PixelData<T>& input_image) {
apr = &aAPR; // in case it was called directly

total_timer.start_timer("Total_pipeline_excluding_IO");
Expand All @@ -155,12 +155,12 @@ bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, MeshData<T>&
//assuming uint16, the total memory cost shoudl be approximately (1 + 1 + 1/8 + 2/8 + 2/8) = 2 5/8 original image size in u16bit
//storage of the particle cell tree for computing the pulling scheme
allocation_timer.start_timer("init and copy image");
MeshData<ImageType> image_temp(input_image, false /* don't copy */); // global image variable useful for passing between methods, or re-using memory (should be the only full sized copy of the image)
MeshData<ImageType> grad_temp; // should be a down-sampled image
PixelData<ImageType> image_temp(input_image, false /* don't copy */); // global image variable useful for passing between methods, or re-using memory (should be the only full sized copy of the image)
PixelData<ImageType> grad_temp; // should be a down-sampled image
grad_temp.initDownsampled(input_image.y_num, input_image.x_num, input_image.z_num, 0);
MeshData<float> local_scale_temp; // Used as down-sampled images for some averaging steps where it is useful to not lose precision, or get over-flow errors
PixelData<float> local_scale_temp; // Used as down-sampled images for some averaging steps where it is useful to not lose precision, or get over-flow errors
local_scale_temp.initDownsampled(input_image.y_num, input_image.x_num, input_image.z_num);
MeshData<float> local_scale_temp2;
PixelData<float> local_scale_temp2;
local_scale_temp2.initDownsampled(input_image.y_num, input_image.x_num, input_image.z_num);
allocation_timer.stop_timer();

Expand Down Expand Up @@ -206,7 +206,7 @@ bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, MeshData<T>&
method_timer.stop_timer();

method_timer.start_timer("downsample_pyramid");
std::vector<MeshData<T>> downsampled_img;
std::vector<PixelData<T>> downsampled_img;
//Down-sample the image for particle intensity estimation
downsamplePyrmaid(input_image, downsampled_img, aAPR.level_max(), aAPR.level_min());
method_timer.stop_timer();
Expand All @@ -229,7 +229,7 @@ bool APRConverter<ImageType>::get_apr_method(APR<ImageType> &aAPR, MeshData<T>&
}

template<typename ImageType>
void APRConverter<ImageType>::get_local_particle_cell_set(MeshData<ImageType> &grad_temp, MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2) {
void APRConverter<ImageType>::get_local_particle_cell_set(PixelData<ImageType> &grad_temp, PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2) {
//
// Computes the Local Particle Cell Set from a down-sampled local intensity scale (\sigma) and gradient magnitude
//
Expand Down Expand Up @@ -274,7 +274,7 @@ void APRConverter<ImageType>::get_local_particle_cell_set(MeshData<ImageType> &g
}

template<typename ImageType>
void APRConverter<ImageType>::get_gradient(MeshData<ImageType> &image_temp, MeshData<ImageType> &grad_temp, MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2, float bspline_offset) {
void APRConverter<ImageType>::get_gradient(PixelData<ImageType> &image_temp, PixelData<ImageType> &grad_temp, PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2, float bspline_offset) {
// Bevan Cheeseman 2018
// Calculate the gradient from the input image. (You could replace this method with your own)
// Input: full sized image.
Expand Down Expand Up @@ -335,7 +335,7 @@ void APRConverter<ImageType>::get_gradient(MeshData<ImageType> &image_temp, Mesh
}

template<typename ImageType>
void APRConverter<ImageType>::get_local_intensity_scale(MeshData<float> &local_scale_temp, MeshData<float> &local_scale_temp2) {
void APRConverter<ImageType>::get_local_intensity_scale(PixelData<float> &local_scale_temp, PixelData<float> &local_scale_temp2) {
//
// Calculate the Local Intensity Scale (You could replace this method with your own)
//
Expand Down Expand Up @@ -385,7 +385,7 @@ void APRConverter<ImageType>::get_local_intensity_scale(MeshData<float> &local_s


template<typename ImageType> template<typename T>
void APRConverter<ImageType>::init_apr(APR<ImageType>& aAPR,MeshData<T>& input_image){
void APRConverter<ImageType>::init_apr(APR<ImageType>& aAPR,PixelData<T>& input_image){
//
// Initializing the size of the APR, min and maximum level (in the data structures it is called depth)
//
Expand All @@ -406,7 +406,7 @@ void APRConverter<ImageType>::init_apr(APR<ImageType>& aAPR,MeshData<T>& input_i
}

template<typename ImageType> template<typename T>
void APRConverter<ImageType>::auto_parameters(const MeshData<T>& input_img){
void APRConverter<ImageType>::auto_parameters(const PixelData<T>& input_img){
//
// Simple automatic parameter selection for 3D APR Flouresence Images
//
Expand Down Expand Up @@ -484,7 +484,7 @@ void APRConverter<ImageType>::auto_parameters(const MeshData<T>& input_img){
float proportion_flat = freq[0]/(counter*1.0f);
float proportion_next = freq[1]/(counter*1.0f);

MeshData<T> histogram;
PixelData<T> histogram;
histogram.init(num_bins, 1, 1);
std::copy(freq.begin(),freq.end(),histogram.mesh.begin());

Expand Down

0 comments on commit c5b40a1

Please sign in to comment.