// calculate the reliability of the vertical edges of the image // it is calculated by adding the reliability of pixel and the relibility of // its lower neighbour in the image. private static void verticalEDGEs(PIXELM *pixel, EDGE *edge, int image_width, int image_height, params_t *myparams) { int no_of_edges = myparams->no_of_edges; PIXELM *pixel_pointer = pixel; EDGE * edge_pointer = edge + no_of_edges; for (int i = 0; i < image_height - 1; i++) { for (int j = 0; j < image_width; j++) { //if (pixel_pointer->input_mask == NOMASK && // (pixel_pointer + image_width)->input_mask == NOMASK) //{ edge_pointer->pointer_1 = pixel_pointer; edge_pointer->pointer_2 = (pixel_pointer + image_width); edge_pointer->reliab = pixel_pointer->reliability + (pixel_pointer + image_width)->reliability; edge_pointer->increment = find_wrap( pixel_pointer->value, (pixel_pointer + image_width)->value); edge_pointer++; no_of_edges++; //} pixel_pointer++; } // j loop } // i loop myparams->no_of_edges = no_of_edges; }
// calculate the reliability of the horizontal edges of the image // it is calculated by adding the reliability of pixel and the relibility of // its right-hand neighbour // edge is calculated between a pixel and its next neighbour private static void horizontalEDGEs(PIXELM *pixel, EDGE *edge, int image_width, int image_height, params_t *myparams) { EDGE * edge_pointer = edge; PIXELM *pixel_pointer = pixel; int no_of_edges = myparams->no_of_edges; for (int i = 0; i < image_height; i++) { for (int j = 0; j < image_width - 1; j++) { //if (pixel_pointer->input_mask == NOMASK && // (pixel_pointer + 1)->input_mask == NOMASK) //{ edge_pointer->pointer_1 = pixel_pointer; edge_pointer->pointer_2 = (pixel_pointer + 1); edge_pointer->reliab = pixel_pointer->reliability + (pixel_pointer + 1)->reliability; edge_pointer->increment = find_wrap(pixel_pointer->value, (pixel_pointer + 1)->value); edge_pointer++; no_of_edges++; //} pixel_pointer++; } //pixel_pointer++; } myparams->no_of_edges = no_of_edges; }
// gather the pixels of the image into groups private static void gatherPIXELs(EDGE *edge, params_t *myparams) { PIXELM *PIXEL1; PIXELM *PIXEL2; PIXELM *group1; PIXELM *group2; EDGE * pointer_edge = edge; int incremento; int computed_edges = 0; int non_computed_edges = 0; for (int k = 0; k < myparams->no_of_edges; k++) { PIXEL1 = pointer_edge->pointer_1; PIXEL2 = pointer_edge->pointer_2; // PIXELM 1 and PIXELM 2 belong to different groups // initially each pixel is a group by it self and one pixel can construct a // group // no else or else if to this if if (PIXEL2 != null & PIXEL2 != null) { computed_edges += 1; if (PIXEL2->head != PIXEL1->head) // SJ added check here for if PIXEL2-> head or pixel2-> head is null { // PIXELM 2 is alone in its group // merge this pixel with PIXELM 1 group and find the number of 2 pi to add // to or subtract to unwrap it if ((PIXEL2->next == null) && (PIXEL2->head == PIXEL2)) { PIXEL1->head->last->next = PIXEL2; PIXEL1->head->last = PIXEL2; (PIXEL1->head->number_of_pixels_in_group)++; PIXEL2->head = PIXEL1->head; PIXEL2->increment = PIXEL1->increment - pointer_edge->increment; } // PIXELM 1 is alone in its group // merge this pixel with PIXELM 2 group and find the number of 2 pi to add // to or subtract to unwrap it else if ((PIXEL1->next == null) && (PIXEL1->head == PIXEL1)) { PIXEL2->head->last->next = PIXEL1; PIXEL2->head->last = PIXEL1; (PIXEL2->head->number_of_pixels_in_group)++; PIXEL1->head = PIXEL2->head; PIXEL1->increment = PIXEL2->increment + pointer_edge->increment; } // PIXELM 1 and PIXELM 2 both have groups else { group1 = PIXEL1->head; group2 = PIXEL2->head; // if the no. of pixels in PIXELM 1 group is larger than the // no. of pixels in PIXELM 2 group. Merge PIXELM 2 group to // PIXELM 1 group and find the number of wraps between PIXELM 2 // group and PIXELM 1 group to unwrap PIXELM 2 group with respect // to PIXELM 1 group. the no. of wraps will be added to PIXELM 2 // group in the future if (group1->number_of_pixels_in_group > group2->number_of_pixels_in_group) { // merge PIXELM 2 with PIXELM 1 group group1->last->next = group2; group1->last = group2->last; group1->number_of_pixels_in_group = group1->number_of_pixels_in_group + group2->number_of_pixels_in_group; incremento = PIXEL1->increment - pointer_edge->increment - PIXEL2->increment; // merge the other pixels in PIXELM 2 group to PIXELM 1 group while (group2 != null) { group2->head = group1; group2->increment += incremento; group2 = group2->next; } } // if the no. of pixels in PIXELM 2 group is larger than the // no. of pixels in PIXELM 1 group. Merge PIXELM 1 group to // PIXELM 2 group and find the number of wraps between PIXELM 2 // group and PIXELM 1 group to unwrap PIXELM 1 group with respect // to PIXELM 2 group. the no. of wraps will be added to PIXELM 1 // group in the future else { // merge PIXELM 1 with PIXELM 2 group group2->last->next = group1; group2->last = group1->last; group2->number_of_pixels_in_group = group2->number_of_pixels_in_group + group1->number_of_pixels_in_group; incremento = PIXEL2->increment + pointer_edge->increment - PIXEL1->increment; // merge the other pixels in PIXELM 2 group to PIXELM 1 group while (group1 != null) { group1->head = group2; group1->increment += incremento; group1 = group1->next; } // while } // else } // else } // if pointer_edge++; } else { non_computed_edges += 1; pointer_edge++; } } }