Operationg on separated pixels/making changes in image directly - Script Writing - CHDK Forum  

Operationg on separated pixels/making changes in image directly

  • 3 Replies
  • 3726 Views
Operationg on separated pixels/making changes in image directly
« on: 20 / February / 2011, 14:55:52 »
Advertisements
Hi there!

I've got two questions:

1) Is there any possibility to operate on separated pixels? For example to take a RGB values of one defined pixel from an image?
2) Is there any possibility to create binary file on SD card?

What's I'm trying to do is:
-take a shoot
-make some changes to image
-save output image to SD card.

So I need to read RGB values and then write them in new file (whichever format - jpg, bmp - just binary way).

I guess it's always possible by peek and poke, but I've got not enough knowlege to use it safety and I don't like to couse my camera blow up... Is there any other way?
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline reyalp

  • ******
  • 14118
Re: Operationg on separated pixels/making changes in image directly
« Reply #1 on: 20 / February / 2011, 16:29:41 »
Hi there!

I've got two questions:

1) Is there any possibility to operate on separated pixels? For example to take a RGB values of one defined pixel from an image?
From script, I don't think you will be able to reliably access the raw buffer. The raw buffer is only valid at a certain stage and shooting, script doesn't get called at that exact point. You can do this in C.

The raw buffer format is described in http://chdk.wikia.com/wiki/Frame_buffers

Keep in mind that doing anything on the entire buffer using the camera CPU is quite slow. Canon does it's image processing with dedicated hardware on digic, but we don't currently have control of that.

Quote
2) Is there any possibility to create binary file on SD card?
Lua can write binary files no problem.  If you want to write a large camera buffer directly to disk from Lua, you should use eventprocs rather than io.* library. See http://chdk.wikia.com/wiki/Lua/Lua_Reference/Native_Function_Calls

If you set things up (using C code) to manipulate the raw buffer, you wouldn't need to write anything out from script, just make your changes before the normal raw saving and they will be included. The jpeg is also crated at this point, so they would be included there as well. See core/raw.c
Don't forget what the H stands for.

Re: Operationg on separated pixels/making changes in image directly
« Reply #2 on: 20 / February / 2011, 16:55:22 »
Thank you, reyalp!

Unfortunetly I don't feel well in C, I'm using script languages, such as Python, so probably it's not job for me:/ Maybe some day I'll try. It sounds very interesting, but I'm still newbie.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline reyalp

  • ******
  • 14118
Re: Operationg on separated pixels/making changes in image directly
« Reply #3 on: 20 / February / 2011, 17:42:57 »
Thank you, reyalp!

Unfortunetly I don't feel well in C, I'm using script languages, such as Python, so probably it's not job for me:/ Maybe some day I'll try. It sounds very interesting, but I'm still newbie.
I'd generally recommend doing image processing on your PC after the fact. With raw, there is no processing you could do on the camera that can't be done on the PC. You also have lots more memory, CPU power and storage to work with, and a vast number of languages and software libraries to choose from.

The only downside is you can't see the results while you are shooting.
Don't forget what the H stands for.


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal