Hello,
I am new to PSP scripting. I have inspected a few scripts that come with PSP 8 and notice that they apply a function to the entire canvas (or selection) using the same settings for every pixel. Is it possible instead to blur (for example) each pixel of one image by an amount set by the pixel in the same (x,y) position in another image? One use case would be if I had two outputs from a 3D program: (1) the rendered image, and (2) a Z value image showing the distance from the camera. Let's say I wanted to blur objects further away more than objects that were closer. Here is pseudo code of how I imagine the script to look if the rendered output was 4000x2000 pixels:
Image1=Open(file...)
Image2=Open(file...)
For (x) from 1 to 4000
For (y) from 1 to 2000
distance=Read_pixel(Image2, x,y)
Blur_pixel(Image1,x,y,distance)
End
End
Could someone suggest how this could be accomplished and perhaps point me toward an example in the scripting manual or online?
Thank you,
d. vyd
Filter based on pixel values in a 2nd image?
Moderator: Kathy_9
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Filter based on pixel values in a 2nd image?
Not possible at all with PSP. It'd be easier to just build your own app with Pillow or similar graphics library for Python (if you wanted to stick with python that is)
Scripting in PSP does not allow direct access to pixel information. And the commands simply trigger the built in commands inside PSP so there is no way to force it to use one image vs another.
You can technically use the eyedropper command to update the materials palette and grab the foreground material to find out what color a certain pixel has. But that's extremely slow as each command updates the UI before finishing. The fastest method would either be to a) save the current image in a format your script can read, then read the data in or b) copy the image to the clipboard, access it via win32 apis and interpret the data that way. Not really condusive to advanced filters like you're wanting to perform.
The features you would need just don't exist in PSP. And I'm not familiar enough with GIMP programming to tell you if it could do it.
Scripting in PSP does not allow direct access to pixel information. And the commands simply trigger the built in commands inside PSP so there is no way to force it to use one image vs another.
You can technically use the eyedropper command to update the materials palette and grab the foreground material to find out what color a certain pixel has. But that's extremely slow as each command updates the UI before finishing. The fastest method would either be to a) save the current image in a format your script can read, then read the data in or b) copy the image to the clipboard, access it via win32 apis and interpret the data that way. Not really condusive to advanced filters like you're wanting to perform.
The features you would need just don't exist in PSP. And I'm not familiar enough with GIMP programming to tell you if it could do it.
https://levifiction.wordpress.com/
-
dvyd
- Posts: 2
- Joined: Sat Mar 04, 2017 8:52 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- processor: i7-6820HQ 2.70GH
- ram: 8GB
- Video Card: NVIDIA GeForce 940MX
- Corel programs: Paintshop Pro X8
Re: Filter based on pixel values in a 2nd image?
LeviFiction, thank you for your quick and direct answer. I did not look at the PSP Python scripting manual closely enough when I purchased a year or so ago. PSP is a nice tool for cropping and color correction but clearly not the right fit for my current project.
