We are about to switch to a new forum software. Until then we have removed the registration on this forum.

- All Categories 25.7K
- Announcements & Guidelines 13
- Common Questions 30
- Using Processing 22.1K
- Programming Questions 12.2K
- Questions about Code 6.4K
- How To... 4.2K
- Hello Processing 72
- GLSL / Shaders 292
- Library Questions 4K
- Hardware, Integration & Other Languages 2.7K
- Kinect 668
- Arduino 1K
- Raspberry PI 188
- Questions about Modes 2K
- Android Mode 1.3K
- JavaScript Mode 413
- Python Mode 205
- Questions about Tools 100
- Espanol 5
- Developing Processing 548
- Create & Announce Libraries 211
- Create & Announce Modes 19
- Create & Announce Tools 29
- Summer of Code 2018 93
- Rails Girls Summer of Code 2017 3
- Summer of Code 2017 49
- Summer of Code 2016 4
- Summer of Code 2015 40
- Summer of Code 2014 22
- p5.js 1.6K
- p5.js Programming Questions 947
- p5.js Library Questions 315
- p5.js Development Questions 31
- General 1.4K
- Events & Opportunities 288
- General Discussion 365

Hi, I just started to learn Processing because I need to do some stuffs. I went thru some tutorials about "Images and Pixels" but there is only some basic code how to load and process image and pixels. My question is, there is an example where I can find how to process a image with an exact formula ? what i mean is to load a image, process the image thru a formula and have a output of the loaded image but changed (in a 2nd window "right to the 1st image") with the processed image (formula).

Tagged:

This discussion has been closed.

## Answers

In order to get an independent copy of a PImage, we can use its

get()method:http://processing.org/reference/PImage_get_.html

I understand the copy of an image but what i really mean is to just get the out put of the basic image that will be processed thru a formula and we gonna have a output. example: We load a main/basic image "left" we process it thru e formula and we get the results to the right. That's my question, is there an example where i can learn how to process the image with a mathematical formula and get the results?

here is an example

Here is another example.

In this picture the top picture is the origina; and the bottom picture is a processed copy. The ARGB channels of the original have been moved into AGBR order.

That's helpful but I'm talking about formulas, Gaussian filter, Zonal high pass filter, Butterworth low pass filter, Cos Transform, Homomorphic filtering ....etc

What you saw me there is just manual code, but what i'm talking is formulas, to change a picture with an exact formula.

https://processing.org/reference/tint_.html https://processing.org/reference/blend_.html https://processing.org/reference/filter_.html https://processing.org/reference/shader_.html

@Domino60, you don't say what you want exactly. You just give some vague examples.

And we don't know your skill level.

You've been given some examples and you can work with them.

quark provided a formula.

just use his code, implement your formula in it and come back when you have a concrete problem with your own code you show us then.

;-)

AFAIK the filters you mentioned don't have an exact mathematical formula, rather they are an algorithm that manipulates the pixel colour data. In my code you simply replace line 29 with code that performs the algorithm.

Moved out of Questions about Code, because you don't give any code.

You mention a number of algorithms. That's the starting point for some Web searches, no? The answers above give a framework for testing these algorithms.

quark

You said that in your code i just change the line 29 with my exact formula. Am i right?

To reiterate this again: You're not being clear. We don't know what you mean by a "formula", and honestly, I don't think you know what you mean by it either.

What do you mean? What does your "formula" actually

doto the image?I know what exactly I mean. A mathermatical formula which change the state of each pixel in the image and at the end we got the full picture changed.

For example the Gaussian filter:

I got a mathematical formula which act exactly as in the picture, what i need it to "somehow" place that mathematical formula to change each pixel from the image one by one so in the end i got the changed image.

Hello,

sorry for having been rude.

you wrote:

but that's exactly what happens in the code quark has provided. Get the original pixel, change it (famous line 29), write it back.

Of course you have to translate your formula into the processing language to make it work.

And it won't look the same then. Maybe it isn't on one line even but two or three lines. But your code works on the principle of the formula then.

That's what programming is all about: Translating mathematical formulas or every day concepts (play chess, sort a list) into code that can be executed by a computer

Can you post your formula please?

Then we can translate it to processing code.

When you have different formulas, the user could choose from them and the image looks different each time.

Best,

Chrisir ;-)

have you read this? it goes into image processing using Processing (the software):

https://processing.org/tutorials/pixels/

most non-trivial image processing acts on a 'kernel' of pixels at once rather than an individual pixel. it runs these through a convolution matrix and saves the result. (see Level II: Pixel Group Processing in the above tutorial)

but, yes, post the formula

see, the wikipedia entry for Guassian blur gives you a convolution matrix

https://en.wikipedia.org/wiki/Gaussian_blur#Sample_Gaussian_matrix

it's 7x7 so a lot bigger then the one in the tutorial, but the idea is the same.

Hi, thanks for understanding what i need, I'm new to processing so I'm not an expect with image processing, i need some time to understand what's going on, yes i understood the quarks code that in the line 29 i change each pixel and as you said i need to translate the mathematical formula in to processing code, but is there a way to put the exact formula in the code?

I'm working on a project and the person who i give the project he needs to see the exact formula in the code. He don't know anything about the code but he needs to see the formula "in the code" i know it's different in each programming language but is that possible with processing?

I got this from C coding:

This is as example, in C is different, you need to get the array of pixels and put them in the formula and run them for each pixel a time in a huge code of For's. As i saw in processing here is easier with pixels that's why i wanna try here.

post your formula

there is QScript which works with formulas

i am not sure it works on pixels though

(or explain the guy that programming is always translating and not plain formula...)

Can you give me an example how to translate the formula into code and changing each pixel. And what's the QScript?

Do you mean the C code formula?

Well if you can, but at least an example so i could orientate by it and "translate" myself to code.

you see 2 examples above

the C code is without context, I can't see u n v k

I can see only changing the RGB of each pixel but not actually using a math. formula.

that's a formula written in a programming language

you are a little stubborn here...

ah, here is a full JAVA program on Gaussian

(not for processing)

We need more context surrounding the formula you have posted. We do not know what the values/meaning of the variables j, u, n, N, v, or k in the formula stand for or represent.

this is a processing example what runs kind of

but doesn't give good results

it is based on quark and also the website stated:

it's not a algorithm based on one pixel alone like with quarks example

you can't get rid of the for-loops, because the principle of Gaussian is kind of to compare each pixel to the neighbours in a radius I think

therefore you need a lot of for-loops and stuff going on

(which I messed up to get it running, hence the results are so wrong)

Slightly tweak over @Chrisir's

gaussBlur_1(): :ar!I have closed this discussion because the OP has started a new one on the same topic

here