Commit b4e41668 authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

CHG: relabel_mask has variable width of digits

parent 666f9506
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -46,11 +46,11 @@ int main(int argc, char **argv) {
	//type of mask images
	typedef i3d::GRAY16 MV;

	if (argc != 5) {
	if (argc != 6) {
		cout << "Program relabels given sequence of mask images.\n";
		cout << "Bad number of parameters\nUsage: " << argv[0] << " idFrom idTo countFrom countTo\n" \
	     << "example: " << argv[0] << " 10 20 0 99\n" \
	     << "which will relabel ID 10 to 20 in man_track%03d.tif files from 0 till 99.\n";
		cout << "Bad number of parameters\nUsage: " << argv[0] << " idFrom idTo countFrom countTo digits\n" \
	     << "example: " << argv[0] << " 10 20 0 99 3\n" \
	     << "which will relabel ID 10 to 20 in man_seg%03d.tif files from 0 till 99.\n";
		return -2;
	}

@@ -58,11 +58,16 @@ int main(int argc, char **argv) {
	const MV idTo=atoi(argv[2]);
	const size_t countFrom=atoi(argv[3]);
	const size_t countTo=atoi(argv[4]);
	const int digits=atoi(argv[5]);

	char nameFormat[50];
	sprintf(nameFormat,"man_seg%c.%dlu.tif",'%',digits);
	//std::cout << "format: " << nameFormat << "\n";

	for (size_t T=countFrom; T <= countTo; ++T) {
		//open input mask
		char fn[50];
		sprintf(fn,"man_track%.3lu.tif",T);
		sprintf(fn,nameFormat,T);
		cout << "reading: " << fn << endl;

		i3d::Image3d<MV> mask(fn);