[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Please help How to treat pixels and image to make TWO mouse

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 23
Thread images: 5

File: maxresdefault.jpg (55KB, 1280x720px) Image search: [Google]
maxresdefault.jpg
55KB, 1280x720px
Please help

How to treat pixels and image to make TWO mouse flashlight effects and avoid fucking up the whole image by going over the 255 RGB limit?
>>
i managed to do it by multiplying twice, one per flashlight, and then dividing by -width.

but they go dark when they overlap. No idea how to fix that. Although i can work with this, but if anyone still wants to help, that'd be good
>>
>>58867386
didn't unnderstand what you want but I'm sure I know how to do it
>>
>>58868178
im trying to treat an image pixel by pixel, checking the distance between 2 reference points (say, one is the mouse, the other a random moving point) and each pixel of the image, therefore creating a flashlight effect as the closer pixels to each reference point have a brightness of 1.0 while the ones that are beyond a threshold go dark.

i managed to do all that, im just having trouble understanding how to add those two values without the RGB values going crazy. I used constraint, but it still went crazy until i did what the second post says. Only problem is it's going dark when they overlap
>>
>>58868213
>im trying to treat an image pixel by pixel
How in image editor? Wth some program that opens file, edits it and saves edited copy? With some program with opengl canvas?
>>
>>58868315
processing IDE
all this should happen in real time, the reference points would be blobs, meaning, people walking in a room
>>
>>58868328
so you are writing image processing code?
>>
>>58868341
um.. yea. It's very basic. Processing uses some sort of pseudo javascript btw.
i'm a begginer at programming in general, i'm sure most you can do this shit with your eyes closed
>>
Are the rgb values wrapping around to low numbers? Like did you use mod 255 instead of maximum 255? Are you sure you used maximum 255 and not 0 somehow?

Anyway it sounds like your math is off somewhere, maybe try tracing your RGB values at each step to see what's up.
>>
>>58868359
>fucking up the whole image by going over the 255 RGB limit
Maybe you are simply addimg values? If yes try something like this https://en.wikipedia.org/wiki/Alpha_compositing
>>
>>58868389
i'll check the RGB values and let you know in a minute

what's "mod 255"?
my workflow goes something like this

>grab RGB from each pixel
>compare to mouseXY
>map the distance (min 0, max 100, min 8, max 0) and multiply R, G and B by that value
>repeat with the other ref point
>divide by -width
>constrain RGB between 0,255

im pretty sure the mapping gives negative values or something that i wasn't counting on.

I dunno how to see the values since i can't println inside a FOR. If anything, i can check the last pixel's RGB, and they just show how it lights up and darkens when i can see it does.

>>58868468
i haven't tried to use alpha for this, i dunno if i can even understand that operation but i'll fool around with alpha for a while
>>
>>58868359
Processing uses Java syntax. P5js is a parser for JavaScript into processing. I have experience in p5js, when i get home Ill help you.
>>
>>58868617
thanks bro.
>>
>>58868626
Can you draw or present somehow whats with the flashlight? Would help me understand what you actually want.
>>
File: 0.png (727KB, 1440x900px) Image search: [Google]
0.png
727KB, 1440x900px
>>58868644
this is the full project with blobs and stuff. As you can see by the trail of the image(affected by the lightsource's position), it's only being light up from the right blob's position.

Now, i managed to have two lights working (on a side sketch so i don't fuckup my main project), but as they get closer to each other they darken, until going fully dark when overlapped.

desu my main project would kinda work with this overlapping bug, since overlapping blobs would just be counted as a single blob. But i'd like to make things right.

I also have another problem with storing more than one blob's position. I guess i should use arraylist to make a dynamic array that creates and deletes indexes as blobs come and go? haven't got around to it yet
>>
>>58868690
Literally what the fuck is this?
You want to have two points, both of which will generate light yes? Or what? Or is this supposed to be first person perspective?
I can't understand what you are trying to do.
>>
>>58869116
there's no perspective or 3D, it's a 2D image with pixel treatment so the distance between a certain point and EVERY PIXEL of the image is calculated and the closest to the certain point the pixel is, the brightest it is.

So it looks like a flashlight but there is no light, it's actually a brightness processing on a 2D image. In real time, with more than one "point" to calculate distance
>>
>>58869370
So you have a square on a 2D plane, then you have a point on the same 2D plane. Now the square generates a 'shadow' of itself (gradually getting darker) in the opposite direction of the point. Does the shadow get shorter the closer the point is or is it constant 'length'?
>>
File: image.jpg (16KB, 783x785px) Image search: [Google]
image.jpg
16KB, 783x785px
>>58869512
it's like a gradient. These look dim as fuck but dont mind that, i can turn up the ammount of light if i wanted to.
The thing is, the closer each "point" gets to the other one, they both get darker, to the point of complete darkness when they overlap, and two full bright points when they're as further away as they can be
>>
>>58869558
Oh now I understand. so it makes everything around the point visible gradually dimming it. Sort of like fog of war in games right?
>>
>>58869558
Why not draw X (let's say 100) circles around the point (x,y) which will vary in opacity? From transparent to opaque at the end. And make everything else except the circle dark.
>>
>>58869715
it would simplify the maths surely, but it would diminish my resolution. Althought the "using opacity" AKA alpha might do the trick.. i said i would try it and i forgot.

I'm on it now.
>>
File: image.jpg (49KB, 783x779px) Image search: [Google]
image.jpg
49KB, 783x779px
I managed to get something working where the two points generate some sort of ellipse, so the closest they get, the brightest and roundest, the further away, darker and thinner ellipse.
It's not what i wanted exactly but it'd work pretty well for what im doing. I just have to figure out a little color offset that i'm getting when there's more than 2 points.

I just applied the distance mapping like this:
>(r is carrying the image values before next line is applied)
>r += map(distance...)+ map(distance2...));
mapping the distances to 127, so they both add 255. And just in case i fuck up and go over 255, i can always rely on constrain before i updatePixels();

I'm still open for any guidance or opinions in case you all care, i have to keep working on this for a while yet
Thread posts: 23
Thread images: 5


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.