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

Added connected components #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added connected components #3

wants to merge 1 commit into from

Conversation

RyanXXYC
Copy link

@RyanXXYC RyanXXYC commented Jan 3, 2024

No description provided.

Copy link
Collaborator

@nguy8tri nguy8tri left a comment

Choose a reason for hiding this comment

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

Great work Ryan, you caught a lot of stylistic things that I wasn't anticipating for new members, so I'm very happy with this! The review here is mainly a stylistic review, and once you're done making the changes, I will then review your code for correctness.


namespace found {

struct Point {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Vec2 instead, which is found in attitude-utils.hpp

struct Edge {
int magnitude; // number of points in this edge
std::vector<Point> points;
// int Xmin, Xmax, Ymin, Ymax;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding these metadata fields in. It may be useful in the future to distinguish between edges that might be part of Earth (in which case, one of these fields should be near the border), and others. Also, relocate the Edge struct to the style.hpp file.


std::vector<Edge> connectedPoints;

for (const auto& pair : params) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not use the auto keyword unless it is extremely inconvenient (i.e. for a variable that holds a function)

@@ -0,0 +1,265 @@
#include <stdio.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename files to edge.cpp and edge.hpp for now

// int Xmin, Xmax, Ymin, Ymax;
};

std::vector<Edge> NaiveConnectedComponent(unsigned char *image, int imageWidth, int imageHeight) { // const??
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless you plan on making a better version, it might be better to name this just as ConnectedComponents or such

// Initial labeling of centroids
for(long i = 1; i < imageHeight * imageWidth; i++) {
// This is specific to the centroiding algo, which tests if this is even part of a centroid
if(image[i] > threshold) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Above, comment with: TODO: Edit this for compatibility with edge filtering


// make an array with the same dimensions of the image, but it shows connected components using numbers
unsigned char *edges = (unsigned char *) std::malloc(imageWidth * imageHeight * sizeof(unsigned char));
edges[0] = (image[0] > threshold) ? 1 : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Above, comment with: TODO: Edit this for compatibility with edge filtering

#include <string.h>
#include <cassert>
#include <cstdlib>

Copy link
Collaborator

Choose a reason for hiding this comment

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

#include your .hpp file here. You'll then notice that there is a double definition, but the below comments will fix that.

};

// Function prototype
std::vector<Edge> NaiveConnectedComponent(unsigned char *image, int imageWidth, int imageHeight);
Copy link
Collaborator

@nguy8tri nguy8tri Jan 4, 2024

Choose a reason for hiding this comment

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

Please put a more descriptive function comment here. There should be:

  1. General Description of the Funciton
  2. Parameter Description
  3. Outputs
  4. Any modifications on the parameters
  5. Preconditions
  6. (optional) Postconditions

You can use @ tags for this. More info here: https://darkognu.eu/programming/tutorials/doxygen_tutorial_cpp/.


}

#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you have completed tests on this function, so I will need you to formalize that in the test suite. That can be found in "found/test/test.cpp" (No .hpp file needed here). example.cpp will help you figure out how to write tests using C++'s CHECK framework (I'm open to other test suites if its better by the way).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants