Skip to content

Commit

Permalink
BUG: filling the buffer was forgotten in CreateImage
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Sep 17, 2021
1 parent a91c350 commit fc491a4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ main(int argc, char * argv[])
unsigned int radius = 5;
std::string outputFilename = "Output.png";

if (argc == 1)
{
image = ImageType::New();
CreateImage(image);
}
else if (argc < 4)
if (argc >= 4)
{
image = itk::ReadImage<ImageType>(argv[1]);

Expand All @@ -55,6 +50,11 @@ main(int argc, char * argv[])

outputFilename = argv[3];
}
else
{
image = ImageType::New();
CreateImage(image);
}

std::cout << "Radius: " << radius << std::endl;
using StructuringElementType = itk::BinaryBallStructuringElement<ImageType::PixelType, ImageType::ImageDimension>;
Expand Down Expand Up @@ -98,7 +98,7 @@ main(int argc, char * argv[])
void
CreateImage(ImageType * const image)
{
// Create an image with 2 connected components
// Create an image with a gray square
itk::Index<2> corner = { { 0, 0 } };

itk::Size<2> size;
Expand All @@ -110,7 +110,7 @@ CreateImage(ImageType * const image)
itk::ImageRegion<2> region(corner, size);

image->SetRegions(region);
image->Allocate();
image->Allocate(true);

// Make a square
for (unsigned int r = 40; r < 100; r++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ main(int argc, char * argv[])
unsigned int radius = 5;
std::string outputFilename = "Output.png";

if (argc == 1)
{
image = ImageType::New();
CreateImage(image);
}
else if (argc < 4)
if (argc >= 4)
{
image = itk::ReadImage<ImageType>(argv[1]);

Expand All @@ -55,6 +50,11 @@ main(int argc, char * argv[])

outputFilename = argv[3];
}
else
{
image = ImageType::New();
CreateImage(image);
}

std::cout << "Radius: " << radius << std::endl;
using StructuringElementType = itk::BinaryBallStructuringElement<ImageType::PixelType, ImageType::ImageDimension>;
Expand Down Expand Up @@ -111,7 +111,7 @@ CreateImage(ImageType * const image)
itk::ImageRegion<2> region(corner, size);

image->SetRegions(region);
image->Allocate();
image->Allocate(true);

// Make a square
for (unsigned int r = 40; r < 100; r++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ main(int argc, char * argv[])
std::string outputFilename = "Output.png";
unsigned int iteration = 1;

if (argc == 1)
{
image = ImageType::New();
CreateImage(image.GetPointer());
}
else if (argc < 4)
if (argc >= 4)
{
image = itk::ReadImage<ImageType>(argv[1]);

Expand All @@ -59,6 +54,11 @@ main(int argc, char * argv[])

outputFilename = argv[3];
}
else
{
image = ImageType::New();
CreateImage(image.GetPointer());
}

std::cout << "Iterations: " << iteration << std::endl;

Expand Down Expand Up @@ -94,7 +94,7 @@ CreateImage(TImage * const image)
typename TImage::RegionType region(corner, size);

image->SetRegions(region);
image->Allocate();
image->Allocate(true);

// Make a square
for (int r = 40; r < 100; r++)
Expand Down

1 comment on commit fc491a4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.