Im running this code on an image that is 135 by 200 pixels. thats 27000 pixels...

Im running this code on an image that is 135 by 200 pixels. thats 27000 pixels. I have 3 nested for loops that run for each pixel. (not quite, the second loop isnt run for every element in the first, and the third loop isnt run for every element in the second, but close enough)

It has been almost 20 minutes since I started running the program, and its not finished yet... How long is this going to take guys?

Attached: Capture.png (945x384, 58K)

Other urls found in this thread:

en.wikipedia.org/wiki/Flood_fill
twitter.com/SFWRedditVideos

Stop the calculation at 100 pixels and time that

so like
for p

with both the original running and the new one running, so far it has taken 2 minutes and it has not finished the first 100 pixels. Its a duel core processor, and each thread is taking up about 50% of the total, so there isnt much room for overhead...

why would anyone need 3 nested loops for 2 dimensions

>remove black only outside of borders

Shouldn't you first solve the problems with nogs in your own country?

what is it supposed to do?

im trying to make all black pixels that are outside of an outline of a character. It would be really easy if all the pixels inside the border were not black, but a lot of them are. So I am checking to see if any pixel to the left or to the right is not black, and only if there are no non black pixels to both the left and right do I make the pixel in question transparent.

...

> running 273*109loops
> wut it's been 20 minutes on my 2002 computer and it's not done yet
intredasting

27^3*10^9

i dont even understand you. pls explain again. pls use images

vectorize it and use numpy and PIL, this is a really inefficient way to do it

Attached: hethehyfr.png (1843x581, 94K)

Show us the image and tell us basically what you want to output to be

I've constructed images by plotting pixels like this before so it should be easy

Was waiting for this.

Attached: 15423946671777562.png (672x684, 652K)

OP here. I know this is an assbackwards way of doing this. Im tweaking the code, will post when thats done. This is what Im trying to do.

Attached: Chara.jpg (1000x1000, 351K)

Attached: 1470212644806.jpg (960x944, 58K)

Can't you just use the bucket tool in paint lmao

oh all of it was suppose to be blue and green? I thought he intentionally left the black in there

This is what you end up with when you fail signals class. In other words: how to do something in two eternities instead of writing a simple filter.

pic
it would not catch the part between the legs

Attached: 1541918935991.jpg (183x275, 6K)

ALRI-ALRI-ALRI--- LISTEN OP I GOT THE SOLUTION FOR YOU. IM HIGH AS A CAKE BUT HERES WHAT WE HAVE SO FAR OK:

- WE HAVE A MOTHERFUCKING SPRITE, THAT HAS NO PROPER ALPHA CHANNEL SET => AROUND THE FIGURE IS BLACKNESS

NOW THIS IS WHAT OP SUGGESTED: PROGRAMMATICALLY CREATE 3 NESTED LOOPS TO REMOVE THE BLACKNESS

NOW THIS IS THE REAL SOLUTION: OPEN PHOTOSHOP AND REMOVE THE BLACK USING THE MAGIC ERASER TOOL, AND RESAVING THE SPRITE WITH PROPER ALPHA CHANNEL SET ALREADY.

THANK YOU FOR LISTENING FOLKS IT WAS A GREAT NIGHT AGAIN WITH YOU GUYS

Attached: 1438114215690.jpg (600x922, 211K)

I'd like to see you do this with filters.

>the part between the legs
You mean her penis?

Attached: 1419615446204.jpg (450x325, 16K)

Go through each row and fi d the first and last nonblack pixel. And make the pixels before the first nonblack pixel and after the last nonblack pixel transparent.

This isn't a very good way, but it's better than your retarded way, and I think you'll be able to manage implementing it

outline -> flood edge
wow such a damn hard filter
i almost had to think
matlab code incoming

this is unironically the solution. just implement a flood fill using bfs

That's actually not going to work like you think it would because a lot of black pixels are between two non-black.

Are you using the word 'filter' here as 'a photoshop command'?

Attached: x.png (135x200, 13K)

What are you using to manipulate images?
Probably has some function to do this already

Do you want to take down all black pixels that have other black pixels *somewhere* to the right and left? Or *immediately* to the right and left? With the former, that would include all of her hair.

If you want the latter, you want to find a function that returns a pixel by coordinate. Something like `l = getPixel(sprite, getX(p) - 1, getY(p))`.

OP is clearly using this as a programming exercise, not as the most efficient way of manipulating images.

jesus christ just put a print every pixel how hard is that to understand?

'filter' as in DSP filter

How do you make a flood edge filter.

en.wikipedia.org/wiki/Flood_fill
Also it's gonna fail unless you manually fix the gaps in the outline

I only want to remove a black pixel if ALL pixels to its left are black AND if ALL pixels to its right are black. So if a black pixel has a non black pixel on both its left and right, it should be un altered.

Maybe try dividing the image into quadrants?

In pic related, quad A: scan left to right top to bottom erasing each consecutive black pixel until you run into a nonblack pixel
quad B: scan right to left, top to bottom
quad C: scan left to right, bottom to top
quad D: scan right to left, bottom to top

Attached: Untitled.png (490x509, 30K)

absolute state of Jow Forums
fucking retards

for every row:
go from left to right removing everything until you see a non-white pixel
also go from right to left doing the same

Did you understand OP correctly? You can't just do convolution with a 3x3 kernel, he wants to look at every pixel in the row.

That's how the approach you described would look.

import numpy as np
import PIL
import PIL.Image

img = np.asarray(PIL.Image.open('test.png').convert('RGBA')).copy()
target=img[0][0].copy()
for r in range(img.shape[0]):
for c in range(img.shape[1]):
v=img[r][c]

if not np.array_equal(v,target):
break

v[3]=0

for c in reversed(range(img.shape[1])):
v=img[r][c]

if not np.array_equal(v,target):
break

v[3]=0

PIL.Image.fromarray(img,'RGBA').save('res.png')


lol

Attached: res.png (135x200, 2K)

by outputting 0 along edge normals, it's trivial
now shush and wait for the matlab code

Attached: ocCYb5E.png (404x599, 27K)

You can't do it with a filter.

Out of all languages you could use to do this why the fuck did you decide to use jython?

is jython even a language? I thought it was just execution environment for python.

It runs a separate interpreter and is in no way tied to cpython.
It's just semantics, I call python3 a different language from python2.

A little bit easier to read version.

import numpy as np
import PIL
import PIL.Image

img = np.asarray(PIL.Image.open('test.png').convert('RGBA')).copy()
target = img[0][0].copy()

for row in img:
for pixel in row:
if not np.array_equal(pixel,target):
break

pixel[3]=0

for pixel in reversed(row):
if not np.array_equal(pixel,target):
break

pixel[3]=0

PIL.Image.fromarray(img,'RGBA').save('res.png')

OP here. I have found a way to do it faster. Its still slow, but it WILL finish in probably 10 ish minutes.

I did see the issue of leaving in the black in areas I would not want to leave it. Not sure how to fix it though, so will probably just do it manually really carefully.


In retrospect, I should have just done this whole thing manually...

The code I posted finishes in milliseconds. Doing three nested loops over all pixels for this is insane.

>you can't project between spaces

Attached: 1538950193231.jpg (758x768, 57K)

The only think you're capable of apparently is posting brainlet pictures.

>being this buttmad upon being reminded of not understanding undergrad material

Attached: giphy.gif (700x704, 295K)

well Pillow on python had a fill function
just use that

underrated

Attached: anime_floppy_slotter.jpg (850x984, 73K)

>duel core processor
Of course its slow, your cores are fighting each other instead of working together.

OP here. This thread is a monument to my idiocy. Believe it or not, I actually made this thread with this intent.

The really funny thing is I cant think of how to spell it even after you have pointed it out.