choosehappy / QuickAnnotator

An open-source digital pathology based rapid image annotation tool
BSD 3-Clause Clear License
74 stars 27 forks source link

Question on importing annotations using script #17

Closed darshats closed 2 years ago

darshats commented 2 years ago

Hi, What should the mask image be like when importing pre-existing annotation via script? Looking at the code comment in the script:

--- Negative class: [255,0,255], Positive class: [255,255,255], seen but unknown [0,0,255]

I created the base rgb image, and under mask folder in the same directory I placed the mask image. The mask image has magenta background (255,0,255) and white annotation (255,255,255). But when looking at the imported image, something seems to have gone wrong. I have attached my images here. Must be something simple I need change, hopefully! sample sample_mask

Thanks for your help! Darshat

choosehappy commented 2 years ago

I quickly looked at the script you're referring to, and I'm close to 100% sure that there is a typo

The positive class should be [0,255,255], since it should be creating something like a bitwise mask indicating RGB --- > [negative,positive,seen]

it should look something like this:

image

@tasvora can you take a closer look and update the script if needed?

darshats commented 2 years ago

Hello, I made the change to generate correct mask but still there is a problem. The lines of code in the script are like this: toupload = np.zeros((nrow,ncol,3),dtype=np.uint8) toupload[:,:,2]=255 toupload[:,:,0]=(mask[:,:,0]==False)255 toupload[:,:,1]=(mask[:,:,0]>0)255 #### ??

The last line is doubtful - it has the same semantics as the middle line i.e. if the R layer is non-zero then set the left hand side to 255. What is the expected toupload ? cant you just copy the mask into it?

darshats commented 2 years ago

This seems to work - the opencv BGR format needs to be accounted for: toupload[:,:,2]=255 toupload[:,:,0]=(mask[:,:,2]>0)255 toupload[:,:,1]=(mask[:,:,1]>0)255

choosehappy commented 2 years ago

yup, that would explain it

here is where we swap it back:

https://github.com/choosehappy/QuickAnnotator/blob/466c6aa1d9f16fd3f7e934658d9dd2e8eb93d89e/QA_api.py#L683

Apologies for the oversight!

Can you submit a pull request with the needed changes so we can provide the updated version to others?

NdaAzr commented 2 years ago

I am wondering how we can import the existing annotation to this platform. Is there any script available for this?

choosehappy commented 2 years ago

Yup, via scripting:

https://github.com/choosehappy/QuickAnnotator/blob/main/cli/import_annotations_cli.py

On Mon, Aug 22, 2022 at 6:36 PM Neda Azarmehr @.***> wrote:

I am wondering how we can import the existing annotation to this platform. Is there any script available for this?

— Reply to this email directly, view it on GitHub https://github.com/choosehappy/QuickAnnotator/issues/17#issuecomment-1222612231, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJ3XTCUBXTYSAHA5COU33LV2OUATANCNFSM5NA5KVIA . You are receiving this because you commented.Message ID: @.***>