#π is that better and if yes why and what can i improve
39 messages Β· Page 1 of 1 (latest)
@pine path
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
the old one for row in range(90, height+1, 60):
cv2.line(result, (0, row), (width, row), (255, 0, 0), 3)
for cal in range(90, width+1, 60):
import itertools
x_coords = ...
y_coords = ...
for x, y in itertools.product(x_coords, y_coords):
...
If you want to do it with a single loop
@pine path
is it just for prefence or faster then the numpy version
Well you are already looping through each item, so numpy will not make that much of a difference
So might as well write it in a way that is simpler to understand
What you are looking for is a "cartesian product". This is implemented in itertools, but can also be done with a nested for loop.
where ever i go i have been told to get rid of the for loop can i do that if i want to do Image[x_coords:x_coords+90;y_coords:y_coords+90] to make a subimage
Well yeah, but you are doing for y, x in zip(y_grid.flat, x_grid.flat): anyways
And in that loop you do some operations probably, so the itertools.product will not make the program much slower
If you want to remove loops, then you have to use some numpy function that can be performed on every pair of coordinates
i testet it and it is about the same
i lost you on that one what is that i need and is there such a thing
I don't know what you are trying to do
I don't know what you are comparing to so no clue about it being "better" or not, but it is really bad objectively speaking - you really shouldn't be iterating over things when using numpy
so what I want to do is. I have an image I this Image is in grayscale and i want to tear it on subimages with the size 90*90 and then get the average the pixels within an subimage @lost perch and @stable mural
can't you just use a 2d convolutional operation for that?
Yeah sounds like convolution π
What import do i need for that
Could use scipy for that
ty
might take a little trial and error to get the right shape if you never touched it before
1/(90*90)
yeah
@lost perch or @stable mural does this modul also have a step size canΒ΄t like a convlutional layer in keras
It does not
ah that is wonderfull XD
so how can i how separate separatete the image with that funktion in this size num_rows = image.shape[0] // target_height
num_cols = image.shape[1] // target_width
it is not the dont want to make a simple feater map with the same size but rather somthing like averege pooling
found something
ty it kinda safed me 0,04 FPS tbh that is because i had to make a another for loop which i might beable to get rid of later
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.