|
ThreeB 1.1
|
Functions | |
| Image< byte > | scale_to_bytes (const Image< float > &im, float lo, float hi) |
| void | test_output_patch_variance (const vector< Image< float > > &ims) |
| template<class C > | |
| void | assert_same_size (const C &images) |
| Image<byte> scale_to_bytes | ( | const Image< float > & | im, |
| float | lo, | ||
| float | hi | ||
| ) |
Scales an image in to the correct range for bytes.
| hi | Brightest pixel in the image |
| lo | Dimmest pixel in the image |
| im | Image to scale |
Definition at line 9 of file debug.cc.
Referenced by FitSpots::optimize_each_spot_in_turn_for_several_passes(), test_output_patch_variance(), and FitSpots::try_modifying_model().
{
Image<byte> out(im.size());
for(int r=0; r < out.size().y-0; r++)
for(int c=0; c < out.size().x-0; c++)
out[r][c] = (int)floor((im[r][c]-lo)*255/(hi-lo));
return out;
}
| void test_output_patch_variance | ( | const vector< Image< float > > & | ims | ) |
Find the variance of every patch in the image and save it to a file.
| ims | List of images. |
Definition at line 23 of file debug.cc.
References assert_same_size(), scale_to_bytes(), and sub_images().
{
assert_same_size(ims);
int rr = GV3::get<int>("test.variance.radius", 1, -1);
ImageRef r(rr, rr);
ImageRef size = r*2 + ImageRef(1,1);
Image<float> stds(ims.front().size(), 0);
ImageRef p;
for(ImageRef p(0,0); p.y < stds.size().y - size.y; p.y++)
{
for(p.x=0; p.x < stds.size().x - size.x; p.x++)
stds[p + r] = sqrt(mean_and_variance(sub_images(ims, p, size)).second);
}
SubImage<float> s = stds.sub_image(ImageRef(2,2), stds.size() - ImageRef(4,4));
float hi = *max_element(s.begin(), s.end());
float lo = *min_element(s.begin(), s.end());
cerr << hi << " " << lo << endl;
img_save(scale_to_bytes(stds, lo, hi), "test_variance.png");
}
| void assert_same_size | ( | const C & | images | ) |
Determines that all images in the incoming container are the same size, and that the container is not empty.
| images | Container to check |
Definition at line 11 of file debug.h.
Referenced by auto_fixed_scaling(), average_image(), FitSpots::FitSpots(), generate_state_parameters_ye_olde(), SampledMultispot::GibbsSampler::GibbsSampler(), SampledMultispot::GibbsSampler2::GibbsSampler2(), and test_output_patch_variance().
{
assert(!images.empty());
for(typename C::const_iterator i=images.begin(); i != images.end(); i++)
assert(i->size() == images.front().size());
}
1.7.4