Giter Site home page Giter Site logo

Comments (9)

ChristianMarzahl avatar ChristianMarzahl commented on August 20, 2024

Dear StormyaP,

is "closed" set in your settings?
image

from exact.

MingxuanGu avatar MingxuanGu commented on August 20, 2024

from exact.

MingxuanGu avatar MingxuanGu commented on August 20, 2024

image

this is my setting

from exact.

ChristianMarzahl avatar ChristianMarzahl commented on August 20, 2024

@OettlM do you have an idea?

With kind regards,
Christian

from exact.

OettlM avatar OettlM commented on August 20, 2024

@MingxuanGu can you share the way the second image is created? How to you convert the polygon vector to pixel wise segmentations?

from exact.

MingxuanGu avatar MingxuanGu commented on August 20, 2024

I first exported the annotation.
image
Then I read in the .txt file with

csv_file = pd.read_csv(annotation_dir, sep='|', header=None, names=columns, index_col=False)

I created a label array to be filled with labels

anno = np.zeros((20, 2038, 1996))

Then I loop over the "csv_file" and get the vector, class name, and frame number of each row in the "csv_file"

for i in range(len(csv_file)):
    vector_dir = csv_file.loc[[i]].vector[i]
    vector_dir = ast.literal_eval(vector_dir)
    class_name = csv_file.loc[[i]].class_name[i]
    class_num = 1 if class_name == 'Blood_vessel_polygon' else 2
    frame_num = csv_file.loc[[i]].frame[i]
    j = 0
    while 1:
        try:
            coordx = vector_dir['x' + str(j)]
            coordy = vector_dir['y' + str(j)]
            anno[frame_num - 1, coordy, coordx] = class_num
        except KeyError:
            break
        j += 1

After that, I fill the holes for each object in both class:

from scipy.ndimage.morphology import binary_fill_holes
anno1 = np.where(anno == 1, 1, 0)
anno2 = np.where(anno == 2, 1, 0)
for i in range(len(anno1)):
    anno1[i] = binary_fill_holes(anno1[i])
    anno2[i] = binary_fill_holes(anno2[i])
anno = np.where(anno1 == 1, 1, anno)
anno = np.where(anno2 == 1, 2, anno)

At the end, I get this "anno" as the label.

from exact.

OettlM avatar OettlM commented on August 20, 2024

Okay, I think I see where the issue is here.
The data you get is a vector containing each point that is part of the polygon annotation.

What you do in your code is to assign each pixel the value of the point it contains. However, the annotations in EXACT are polygons, so you dont nessesarly have a point for every pixel of the contour, since it just connects each point to the next.

A solution to this behaviour would be to use a function that interprets the vector as a polygon and draws it into your image.
OpenCV offers functionality to easily do that. https://docs.opencv.org/3.4/d4/d73/tutorial_py_contours_begin.html

image

Here is an example how you can use cv2.drawContours to draw the polygons. You can ignore the middle part where I sort the annotations, depending on the area size, which is only relevant if you have overlapping annotations.

In this case the function is also parameterized to directly draw filled polygons, so you dont have to do that yourself afterwards.

from exact.

MingxuanGu avatar MingxuanGu commented on August 20, 2024

Amazing, it works! Thanks!

from exact.

ChristianMarzahl avatar ChristianMarzahl commented on August 20, 2024

Big thanks to @OettlM

from exact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.