Help needed to decide how to proceed

Discuss any general programming issues here
Post Reply
ilbarbax
Posts: 152
Joined: Thu Apr 01, 2010 6:41 pm

Help needed to decide how to proceed

Post by ilbarbax »

Hi
I have a problem to solve and I wand to find the best and quicker solution that atm I can't see.

the problem is:
I have a b/w image that has been originally filtered with a base color (i.e green), therefore the level of gray should represent the green level of the image.
The same is for red and blue.
So now I want to recreate the colored image mixing the 3 filtered images. For the same pixel a certain color should be defined by the rgb value of each gray image. Hope to have explained the situation.
Note that is true if I correctly understood the original behavior. (I'm actually studying an original patent from my gran father that in 1930 using filters and prisms was able to project colored movies, and I want to replicate the process starting from some original films I have scanned on the pc)
Note that this is intended for a single photo-gram of a movie that why should be quick.

I see a solution using brushtorgbarray and then manage the rgb intensity but I believe would not be quick enough.
I also thought to over impose a colored brush and mix the brushes playing with the alpha channel.

Hope for some hint.
thanks
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Help needed to decide how to proceed

Post by Flinx »

I suspect that a Hollywood script is no faster than the BrushToRGBArray() solution. I got 230ms for 800*600 here. If that's too slow, then maybe you could try putting the function into a plugin.

Code: Select all

@DISPLAY {Width = 800, Height = 600}
h=GetAttribute(#DISPLAY, 1, #ATTRHEIGHT)
w=GetAttribute(#DISPLAY, 1, #ATTRWIDTH)
CreateGradientBrush(1, w, h, #LINEAR, 0, 0xffffff,   0)
DisplayBrush(1, 0, 0)
Wait(400,#MILLISECONDS)
CreateGradientBrush(2, w, h, #LINEAR, 0, 0xffffff, 135)
DisplayBrush(2, 0, 0)
Wait(400,#MILLISECONDS)
CreateGradientBrush(3, w, h, #LINEAR, 0, 0xffffff, 270)
DisplayBrush(3, 0, 0)
tableR = BrushToRGBArray(1)
tableG = BrushToRGBArray(2)
tableB = BrushToRGBArray(3)

StartTimer(1)
DisableLineHook()
For i=0 To TableItems(tableR)-1
	tableR[i]=tableR[i]&0xff0000 | tableG[i]&0x00ff00 | tableB[i]&0x0000ff
Next
EnableLineHook()
DebugPrint(GetTimer(1))

RGBArrayToBrush(4, tableR, w, h)
DisplayBrush(4, 0, 0)
WaitLeftMouse()
ilbarbax
Posts: 152
Joined: Thu Apr 01, 2010 6:41 pm

Re: Help needed to decide how to proceed

Post by ilbarbax »

I was approaching a different way however I tried your suggests finding your way better and quicker than mine then thanks, I think it is an excellent way to start.
ilbarbax
Posts: 152
Joined: Thu Apr 01, 2010 6:41 pm

Re: Help needed to decide how to proceed

Post by ilbarbax »

result is quite good now the main problem is the misalignment and deformation between the 3 images that I have cut manually from a picture taken with the smartphone :shock: :shock:
I have to wait for the professional conversion of the film and the continue with the experiments.
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Help needed to decide how to proceed

Post by Flinx »

Then I would expect that the vertical image positions still need to be corrected there as well, but that will be more difficult. Good luck.
Post Reply