Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating RcppArmadillo initialization #10

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/CleanBinaryImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ bool checkStep6(const arma::mat &img, int row, int col)
{
int connectivityCounter = 0;
int blackNeighborCounter = 0;
arma::vec ring = zeros<arma::vec>(9);
ring << img(row, col) << img(row, col+1) << img(row, col+2) << img(row+1, col+2) << img(row+2, col+2) << img(row+2, col+1) << img(row+2, col) << img(row+1, col) << img(row, col);
arma::vec ring( { img(row, col), img(row, col+1), img(row, col+2), img(row+1, col+2), img(row+2, col+2), img(row+2, col+1), img(row+2, col), img(row+1, col), img(row, col) });
for(int i = 0; i < 8; i++)
{
if(ring(i) == 1 && ring(i+1) == 0)
Expand Down
15 changes: 6 additions & 9 deletions src/ThinImageCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ void countBNeighbors_7or8(const arma::mat &img, uvec white, uvec &toBlack)
for(int i = 0; i < white.n_elem; i++)
{
cell = white[i];
neighborInd << img[cell - 1] << img[cell + n - 1] << img[cell + n] << img[cell + n + 1] << img[cell + 1]
<< img[cell - n + 1] << img[cell - n] << img[cell - n - 1];
neighborInd = { img[cell - 1], img[cell + n - 1], img[cell + n], img[cell + n + 1], img[cell + 1], img[cell - n + 1], img[cell - n], img[cell - n - 1] };
isBlack = find(neighborInd == 0);
numBlack = isBlack.n_elem;
if(numBlack >= 7)
Expand Down Expand Up @@ -217,7 +216,7 @@ void count468(const arma::mat &img, uvec checkList, vec &toWhite)
for(int i = 0; i < checkList.n_elem; i++)
{
cell = checkList[i];
neighborInd << img[cell + n] << img[cell + 1] << img[cell - n];
neighborInd = { img[cell + n], img[cell + 1], img[cell - n] };
if(any(neighborInd == 1))
toWhite[i] = 1;
}
Expand All @@ -230,7 +229,7 @@ void count248(const arma::mat &img, uvec checkList, vec &toWhite)
for(int i = 0; i < checkList.n_elem; i++)
{
cell = checkList[i];
neighborInd << img[cell - 1] << img[cell + n] << img[cell - n];
neighborInd = { img[cell - 1], img[cell + n], img[cell - n] };
if(any(neighborInd == 1))
toWhite[i] = 1;
}
Expand All @@ -243,7 +242,7 @@ void count268(const arma::mat &img, uvec checkList, vec &toWhite)
for(int i = 0; i < checkList.n_elem; i++)
{
cell = checkList[i];
neighborInd << img[cell - 1] << img[cell + 1] << img[cell - n];
neighborInd = { img[cell - 1], img[cell + 1], img[cell - n] };
if(any(neighborInd == 1))
toWhite[i] = 1;
}
Expand All @@ -258,8 +257,7 @@ void countBNeighbors(const arma::mat &img, uvec checkList, vec &toWhite)
for(int i = 0; i < checkList.n_elem; i++)
{
cell = checkList[i];
neighborInd << img[cell - 1] << img[cell + n - 1] << img[cell + n] << img[cell + n + 1] << img[cell + 1]
<< img[cell - n + 1] << img[cell - n] << img[cell - n - 1];
neighborInd = { img[cell - 1], img[cell + n - 1], img[cell + n], img[cell + n + 1], img[cell + 1], img[cell - n + 1], img[cell - n], img[cell - n - 1] };
isBlack = find(neighborInd == 0);
numBlack = isBlack.n_elem;
if(numBlack <= 6 && numBlack >= 2)
Expand All @@ -277,8 +275,7 @@ void countWBTransitions(const arma::mat &img, uvec checkList, vec &toWhite)
for(int i = 0; i < checkList.n_elem; i++)
{
cell = checkList[i];
neighborInd << cell - 1 << cell + n - 1 << cell + n << cell + n + 1 << cell + 1
<< cell - n + 1 << cell - n << cell - n - 1 << cell - 1;
neighborInd = { cell - 1, cell + n - 1, cell + n, cell + n + 1, cell + 1, cell - n + 1, cell - n, cell - n - 1, cell - 1 };
counter = 0;
for(int j = 0; j < 8; j++)
{
Expand Down