Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

help with image

Name: Anonymous 2007-05-28 19:28 ID:3Qd527IF

dear /prog/

an image is like a matrix of pixels

i want to blur a portion of the image, so i receive x (int) and y (int) with is the starting point of the image, then I receive width (int) and length (int) to mark the portion to be blurred.

but then the program receives also a variable called 'size' (int), which divides the portion in squares with 'size' of side. in order to blur the image, i must make the average of all the pixels in that square, and make the square with that value of color.

i already made the functions that detect the red, green and blue of a pixel [red(x,y)blue(x,y)green(x,y)] and the functions that write a color to a pixel color(r,g,b,t,x,y).

but i'm having troubles to handle the squares and the matrix of pixels, looks messy. there's like, a fuckload of fors and whiles, no?

can you help me? thanks, adojan

Name: Anonymous 2007-05-28 20:20 ID:PQ4cc2WM

Get Photoshop

Name: Anonymous 2007-05-28 20:34 ID:jmuI2vPm

Name: Anonymous 2007-05-28 21:02 ID:3Qd527IF

>>3

java

Name: Anonymous 2007-05-28 21:44 ID:q9/v2qLM

>>4

no, Logo is clearly the most appropriate language in this case

Name: Anonymous 2007-05-29 0:26 ID:dni2CAGZ

but i'm having troubles to handle the squares and the matrix of pixels, looks messy. there's like, a fuckload of fors and whiles, no?
Fuckload? You'd need at most 2 for loops to loop through your area. Also, putpixel-functions are pretty enterprise. Since you have an array of pixels do it inline.

Name: Anonymous 2007-05-29 1:16 ID:VX8ybqi4

function censor(image, x, y, width, height, size):
  for j in (y .. y + height):
    for i in (x .. x + width):
      bx = int(i / float(size)) * size
      by = int(j / float(size)) * size
      image.putpixel(i, j, image.getpixel(bx, by))

Name: Anonymous 2007-05-29 1:20 ID:015RGIHl

it looks like you're applying a pixelate effect rather than blur.
there are many kinds of blur, but think of what you're trying to do mathematically speaking, then program.
I don't know how to blur but I'm guessing you have to take a pixel, then apply the pixel color to the pixels around it in a circle fashion, with more transparency as you go away from the pixel. This is applied to all pixels.

Name: Anonymous 2007-05-29 1:26 ID:aT8DyqVN

>>6
two loops to go through the area
and two more to calculate the average of the neighborhood pixels

Name: Anonymous 2007-05-29 3:03 ID:o7PVjAQO

ONE QUESTION, WHY DO YOU NEED A PROGRAM TO DO THIS?

Name: Anonymous 2007-05-29 5:48 ID:5BDmpIBO

>>10
maybe it's cheaper and/or more flexible to use a computar instead of some optical blurring apparatus

Name: Anonymous 2007-05-29 6:15 ID:ExbqfrRV

>>1
Why do you want to censor, motherfucker? GTFO my world4ch.

Name: Anonymous 2007-05-29 8:35 ID:Bdz7RTYn

Name: Anonymous 2007-05-29 11:13 ID:2op+Q9Dw

import Image, ImageDraw
import operator as op

def average_pixels(pix, x1, y1, x2, y2):
    pix = im.load()
    sum = (0, 0, 0)
    for y in range(y1, y2):
        for x in range(x1, x2):
            sum = map(op.add, sum, pix[x, y])
    return tuple(c / ((x2 - x1) * (y2 - y1)) for c in sum)

def pixelize(im, x, y, width, height, size):
    draw = ImageDraw.Draw(im)
    for y1 in range(y, y + width, size):
        for x1 in range(x, x + height, size):
            c = average_pixels(im, x1, y1, x1 + size, y1 + size)
            draw.rectangle((x1, y1, x1 + size, y1 + size), fill=c)

Name: Anonymous 2007-05-29 15:17 ID:DpvD0KoP

>>1 is a faggot who wants to censor vaginas

Name: Anonymous 2007-05-29 16:08 ID:XX5Ew+Ex

>>15

not a faggot. i'm testing the program with the head of the developers-developers person.

i just finished the image class http://files-upload.com/257911/Image.htm.html, where i have functions to aid the child class, which will have a lot of normal functions to handle pictures

>>8
yes, that is it - pixelate. basicly a section of the image is divided in squares and i do the color average with the red,green,blue function and i place it in the square

the teacher helped us with the image class, but now we are doing a child class that will use these functions, and is a bit dificult without help

adojan

Name: Anonymous 2007-05-29 19:23 ID:Heaven

>>16
Testing with head = faggot.

Name: Anonymous 2007-05-30 13:29 ID:msU279Ps

i'm a bit stuck still

but thanks for the help so far /prog/

adojan

Name: Anonymous 2007-05-30 14:04 ID:XRgHrDKX

Name: Anonymous 2007-05-30 14:06 ID:XRgHrDKX

Name: Anonymous 2007-05-30 15:27 ID:BW/gEsBD

Gaussian blur in Photoshop:
Filter -> Gaussian Blur -> OK

Name: Anonymous 2007-05-30 15:39 ID:Pm6xANAE

function y = gaussian_blur(x)
h = fspecial('gaussian', 5);
y = filter2(h, x);

Name: Anonymous 2007-05-30 16:00 ID:fyygP8q7

blur it along the x axis and then blur it along the y axis. result is the same, no matrices involved. PROBLEM SOLVED.

Name: Anonymous 2007-05-30 16:24 ID:POKR5gJj

import gd and use one of the blur functions you fucking moron

Name: Anonymous 2007-05-30 22:22 ID:T5CZw9Gr

GD sucks.
import Image

Name: Anonymous 2007-05-31 5:16 ID:fUcz7DOr

>>25
PIL sucks. I can't believe how popular that almost undocumented, buggy pile of crap actually is.

Name: Anonymous 2007-05-31 10:28 ID:Heaven

Script-morons don't know how to write low level libraries or even code that uses low level libraries.

Name: Anonymous 2007-05-31 14:14 ID:Heaven

>>26
Because it's fast and GD isn't?

Name: Anonymous 2009-01-14 14:18

WHBTE

Name: Trollbot9000 2009-07-01 7:58

troubles to handle the squares and the   total number of   iterates 624 in   the case of   MT allows one   to predict all   future iterates Combining.

Name: Anonymous 2010-11-14 12:25


Don't change these.
Name: Email:
Entire Thread Thread List