-
Notifications
You must be signed in to change notification settings - Fork 211
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
Add arbitrary crop module #1607
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1607 +/- ##
==========================================
+ Coverage 55.11% 64.76% +9.64%
==========================================
Files 117 134 +17
Lines 2344 2784 +440
Branches 360 447 +87
==========================================
+ Hits 1292 1803 +511
+ Misses 1052 981 -71
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👍
But there's an issue here, we can't just crop in one step and then overlay in another, coz once you export the image you'll get the black borders again. Since the export would be rectangular. Anyway can you please run this via the cli and confirm what output are we getting. Otherwise we can just do this while overlaying. What do you think?
|
||
function changePixel(r, g, b, a, x, y) { | ||
|
||
if(l1(x, y) * l3(x, y) <= 0 && l2(x, y) * l4(x, y) <= 0) return [r, g, b, a]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey is this the formula that determines whether the point is inside the quadrilateral?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
|
||
// This function is called on every draw. | ||
function draw(input, callback, progressObj) { | ||
progressObj.stop(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need these? I remember taking out the progress code..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't exactly know, should I remove this?
src/modules/ArbitraryCrop/info.json
Outdated
@@ -0,0 +1,48 @@ | |||
{ | |||
"name": "arbitrary-crop", | |||
"description": "Crops image for any arbitrary quadilateral", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a description about which way these coordinates go. Like top left, bottom right and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@tech4GT I fixed that problem by making the alpha channel of other pixels to be 0, after this a meta module can be created for the problem in #1080 using this and overlay module, i've fixed the working of overlay module with transparent image in #1606, after this gets merged that problem can be easily solved by using this meta module |
@tech4GT I am getting this as cli output. These were the inputs |
@tech4GT I've also added the functionality to crop the image so that the quadilateral lies in smallest possible rectangle so we don't have to compute for the extra pixels. This is not showing desired output because extramanipulation is running before changePixel function and generating output according to it, this bug will be fixed in #1564 and it will work normally also I'd really appreciate if you could also review #1564 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey could you try running overlay after arbitrary crop in the cli. Sorry this is taking so long, just want to get this right! :D
@tech4GT I am getting this as cli output This will be fixed when we merge #1606 To make overlay-subpart module we need to first add support for transparent image for overlay module then we need to develop arbitrary-crop and then the module described in #1080 can be easily made by making meta-module of arbitrary-crop and overlay! What do you think? |
Yeah, this is what I was worried about! Let's merge the other PR first then! |
Concerns #1080
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
npm run test-all
@publiclab/is-reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part
Thanks!