How to Create Binary Mask From FreehandRoi Tool
Is there an easy was to create a binary mask from the region of interest drawn using the FreehandRoi tool? All I need is an 512x512 array with the region of interest set to "one" and the rest of the array set to "zero".
I think contour to mask can be fairly straightforward. I recommend taking a look at the Brush's source code, and you'll see how we modify a mask. If you have any specific questions, or if you're hung up on a specific part of the implementation, I can provide more assistance.
The x,y coordinates of the ROI is stored in the points object within the FreehandROI tool in cornerstoneTools.js That object can then be used to draw the ROI on an invisible canvas:
for (i = 0; i < points.length; i += 1) { ctx_canvas_mask.lineTo(points[i].x, points[i].y); }
Then fill the ROI and convert to binary.
Marc
On Wed, Mar 4, 2020 at 9:54 AM Danny Brown [email protected] wrote:
I think contour to mask can be fairly straightforward. I recommend taking a look at the Brush's source code, and you'll see how we modify a mask. If you have any specific questions, or if you're hung up on a specific part of the implementation, I can provide more assistance.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OHIF/Viewers/issues/1478?email_source=notifications&email_token=AGWQ3UWHM5CLH6Z5AFY5VETRFZTSVA5CNFSM4LATAWMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENYHZCQ#issuecomment-594574474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWQ3UXFWA2OVXG4QH7K3J3RFZTSVANCNFSM4LATAWMA .
-- Marc McLean