FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update confidence connected components to use brain scan image by 9prady9 · Pull Request #2968 · arrayfire/arrayfire · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) No extension  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion assets
Show comments Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,52 @@

using namespace af;

array normalize01(const array& in) {
float min = af::min<float>(in);
float max = af::max<float>(in);
return (in - min) / (max - min);
}

void markCrossHair(array& in, const unsigned x, const unsigned y,
const float val) {
const int draw_len = 5;
for (int i = -1; i < 2; i++) {
in(x + i, seq(y - draw_len, y + draw_len), 0) = val;
in(x + i, seq(y - draw_len, y + draw_len), 1) = 0.f;
in(x + i, seq(y - draw_len, y + draw_len), 2) = 0.f;

in(seq(x - draw_len, x + draw_len), y + i, 0) = val;
in(seq(x - draw_len, x + draw_len), y + i, 1) = 0.f;
in(seq(x - draw_len, x + draw_len), y + i, 2) = 0.f;
}
}

int main(int argc, char* argv[]) {
try {
unsigned radius = 3;
unsigned multiplier = 3;
int iter = 5;

array A = loadImage(ASSETS_DIR "/examples/images/donut.png", false);

unsigned seedx = 132;
unsigned seedy = 132;
array ring =
confidenceCC(A, 1, &seedx, &seedy, radius, multiplier, iter, 255);

seedx = 152;
seedy = 152;
array sxArr(dim4(1), &seedx);
array syArr(dim4(1), &seedy);
array core =
confidenceCC(A, sxArr, syArr, radius, multiplier, iter, 255);

seedx = 15;
seedy = 15;
unsigned seedcoords[] = {15, 15};
array seeds(dim4(1, 2), seedcoords);
array background =
confidenceCC(A, seeds, radius, multiplier, iter, 255);

af::Window wnd("Confidence Connected Components demo");
unsigned multiplier = 2;
int iter = 3;

array input =
loadImage(ASSETS_DIR "/examples/images/depression.jpg", false);
array normIn = normalize01(input);

unsigned seedx = 162;
unsigned seedy = 126;
array blob = confidenceCC(input, 1, &seedx, &seedy, radius, multiplier,
iter, 255);

array colorIn = colorSpace(normIn, AF_RGB, AF_GRAY);
array colorOut = colorSpace(blob, AF_RGB, AF_GRAY);

markCrossHair(colorIn, seedx, seedy, 1);
markCrossHair(colorOut, seedx, seedy, 255);

af::Window wnd("Confidence Connected Components Demo");
while (!wnd.close()) {
wnd.grid(2, 2);
wnd(0, 0).image(A, "Input");
wnd(0, 1).image(ring, "Ring Component - Seed(132, 132)");
wnd(1, 0).image(core, "Center Black Hole - Seed(152, 152)");
wnd(1, 1).image(background, "Background - Seed(15, 15)");
wnd.grid(1, 2);
wnd(0, 0).image(colorIn, "Input Brain Scan");
wnd(0, 1).image(colorOut, "Region connected to Seed(162, 126)");
wnd.show();
}
} catch (af::exception& e) {
Expand Down

Back | FazBrowse Home | New Git URL