some comments
This commit is contained in:
parent
93e43941b8
commit
a8b16be07d
@ -59,15 +59,18 @@ void addPixelToSelectedZone(Image *t_img, int64_t t_idx, Zone *t_zone) {
|
|||||||
const uint32_t y = (uint32_t)(t_idx / t_img->sizeX);
|
const uint32_t y = (uint32_t)(t_idx / t_img->sizeX);
|
||||||
int64_t left_limit, right_limit;
|
int64_t left_limit, right_limit;
|
||||||
const int64_t xd_limit = (int64_t)t_img->sizeX * (y + 1);
|
const int64_t xd_limit = (int64_t)t_img->sizeX * (y + 1);
|
||||||
if (t_idx >= (int64_t)img_size || t_idx < 0) {
|
if (t_idx >= (int64_t)img_size || t_idx < 0) { /* Pixel in range? */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_pixel = darrayGet(t_img->pixels, (size_t)t_idx);
|
current_pixel = darrayGet(t_img->pixels, (size_t)t_idx);
|
||||||
|
|
||||||
|
/* Pixel already visited or of the right color? */
|
||||||
if (current_pixel->visited || !sameColor(current_pixel, t_zone)) {
|
if (current_pixel->visited || !sameColor(current_pixel, t_zone)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*current_pixel).visited = 1;
|
(*current_pixel).visited = 1;
|
||||||
|
|
||||||
|
/* right limit */
|
||||||
for (right_limit = t_idx; right_limit < xd_limit; ++right_limit) {
|
for (right_limit = t_idx; right_limit < xd_limit; ++right_limit) {
|
||||||
current_pixel = darrayGet(t_img->pixels, (size_t)right_limit);
|
current_pixel = darrayGet(t_img->pixels, (size_t)right_limit);
|
||||||
if (!sameColor(current_pixel, t_zone)) {
|
if (!sameColor(current_pixel, t_zone)) {
|
||||||
@ -75,6 +78,7 @@ void addPixelToSelectedZone(Image *t_img, int64_t t_idx, Zone *t_zone) {
|
|||||||
}
|
}
|
||||||
current_pixel->visited = 1;
|
current_pixel->visited = 1;
|
||||||
}
|
}
|
||||||
|
/* left limit */
|
||||||
for (left_limit = t_idx; left_limit - (y - 1) * (int64_t)t_img->sizeX >= 0;
|
for (left_limit = t_idx; left_limit - (y - 1) * (int64_t)t_img->sizeX >= 0;
|
||||||
--left_limit) {
|
--left_limit) {
|
||||||
current_pixel = darrayGet(t_img->pixels, (size_t)left_limit);
|
current_pixel = darrayGet(t_img->pixels, (size_t)left_limit);
|
||||||
@ -86,9 +90,11 @@ void addPixelToSelectedZone(Image *t_img, int64_t t_idx, Zone *t_zone) {
|
|||||||
|
|
||||||
darrayPushBack(t_zone->segments,
|
darrayPushBack(t_zone->segments,
|
||||||
newSegment((uint32_t)right_limit, (uint32_t)left_limit));
|
newSegment((uint32_t)right_limit, (uint32_t)left_limit));
|
||||||
|
/* for each pixel of the segment, test the pixel above */
|
||||||
for (; left_limit <= right_limit; ++left_limit) {
|
for (; left_limit <= right_limit; ++left_limit) {
|
||||||
addPixelToSelectedZone(t_img, t_idx + t_img->sizeX, t_zone);
|
addPixelToSelectedZone(t_img, t_idx + t_img->sizeX, t_zone);
|
||||||
}
|
}
|
||||||
|
/* for each pixel of the segment, test the pixel below */
|
||||||
for (; left_limit <= right_limit; ++left_limit) {
|
for (; left_limit <= right_limit; ++left_limit) {
|
||||||
addPixelToSelectedZone(t_img, t_idx - t_img->sizeX, t_zone);
|
addPixelToSelectedZone(t_img, t_idx - t_img->sizeX, t_zone);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user