Commit b710cea43ee2c4f65950a8dabdeb9089d0591337

Authored by Jiaming Guo
1 parent 616c5f99

fixed saving image stack bugs

Showing 1 changed file with 6 additions and 7 deletions   Show diff stats
@@ -1826,7 +1826,7 @@ namespace stim { @@ -1826,7 +1826,7 @@ namespace stim {
1826 cor_v = tmp_v + stim::vec3<T>(-coef_left * origin_l, 0, 0); // get the original corner vertex 1826 cor_v = tmp_v + stim::vec3<T>(-coef_left * origin_l, 0, 0); // get the original corner vertex
1827 desire_l = desire_l - origin_l * (1.0f - ratio / 1.0f); 1827 desire_l = desire_l - origin_l * (1.0f - ratio / 1.0f);
1828 origin_l = (T)origin_l * ratio / 1.0f; 1828 origin_l = (T)origin_l * ratio / 1.0f;
1829 - n = find_number_square(origin_l, desire_l); 1829 + n = find_number_square(origin_l, desire_l, times);
1830 1830
1831 width = (T)origin_l / (2 * n); // updates 1831 width = (T)origin_l / (2 * n); // updates
1832 height = (desire_l - origin_l) / (2 * n); 1832 height = (desire_l - origin_l) / (2 * n);
@@ -1838,7 +1838,7 @@ namespace stim { @@ -1838,7 +1838,7 @@ namespace stim {
1838 origin_l = tmp_l; 1838 origin_l = tmp_l;
1839 1839
1840 std::cout << "Warning: current ratio is not feasible, use full original line." << std::endl; 1840 std::cout << "Warning: current ratio is not feasible, use full original line." << std::endl;
1841 - n = find_number_square(origin_l, desire_l); 1841 + n = find_number_square(origin_l, desire_l, times);
1842 1842
1843 width = (T)origin_l / (2 * n); // updates 1843 width = (T)origin_l / (2 * n); // updates
1844 height = (desire_l - origin_l) / (2 * n); 1844 height = (desire_l - origin_l) / (2 * n);
@@ -1869,7 +1869,7 @@ namespace stim { @@ -1869,7 +1869,7 @@ namespace stim {
1869 height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2); 1869 height = (desire_l - (1 + 2 * n) * origin_l) / std::pow(2 * n, 2);
1870 } 1870 }
1871 1871
1872 - // degenerated case 1872 + // degenerated case, compromise
1873 if (n == 0) { 1873 if (n == 0) {
1874 n = 1; 1874 n = 1;
1875 width = (T)(origin_l) / (2 * n); 1875 width = (T)(origin_l) / (2 * n);
@@ -2666,12 +2666,12 @@ namespace stim { @@ -2666,12 +2666,12 @@ namespace stim {
2666 } 2666 }
2667 2667
2668 Yt = top + 2 * radius; // top bound y coordinate 2668 Yt = top + 2 * radius; // top bound y coordinate
2669 - Yb = bottom + 2 * radius; // bottom bound y coordinate 2669 + Yb = bottom - 2 * radius; // bottom bound y coordinate
2670 Z = (bb.B[2] - bb.A[2] + 2 * max_radius); // bounding box width(along z-axis) 2670 Z = (bb.B[2] - bb.A[2] + 2 * max_radius); // bounding box width(along z-axis)
2671 } 2671 }
2672 2672
2673 /// making image stack main function 2673 /// making image stack main function
2674 - void make_image_stack(stim::image_stack<unsigned char, T> I, T dx, T dy, T dz, std::string stackdir, bool prototype = false, T radius = 5.0f) { 2674 + void make_image_stack(stim::image_stack<unsigned char, T> &I, T dx, T dy, T dz, std::string stackdir, bool prototype = false, T radius = 5.0f) {
2675 2675
2676 /// preparation for making image stack 2676 /// preparation for making image stack
2677 T X, Xl, Xr, Y, Yt, Yb, Z; 2677 T X, Xl, Xr, Y, Yt, Yb, Z;
@@ -2679,11 +2679,10 @@ namespace stim { @@ -2679,11 +2679,10 @@ namespace stim {
2679 X = Xr - Xl; // bounding box length(along x-axis) 2679 X = Xr - Xl; // bounding box length(along x-axis)
2680 Y = Yt - Yb; // bounding box height(along y-axis) 2680 Y = Yt - Yb; // bounding box height(along y-axis)
2681 stim::vec3<T> center = bb.center(); // get the center of bounding box 2681 stim::vec3<T> center = bb.center(); // get the center of bounding box
2682 - T size_x, size_y, size_z; 2682 + int size_x, size_y, size_z;
2683 2683
2684 if (!prototype) { 2684 if (!prototype) {
2685 /// make 2685 /// make
2686 - stim::image_stack<unsigned char, T> I;  
2687 size_x = X / dx + 1; // set the size of image 2686 size_x = X / dx + 1; // set the size of image
2688 size_y = Y / dy + 1; 2687 size_y = Y / dy + 1;
2689 size_z = Z / dz + 1; 2688 size_z = Z / dz + 1;