A odd thing is that I am getting massive values for the amplitude calculation. Around 10^14
I think
(sin(omega-alpha)-sin(omega+alpha))
Can result in zero or very small numbers near zero
A odd thing is that I am getting massive values for the amplitude calculation. Around 10^14
I think
(sin(omega-alpha)-sin(omega+alpha))
Can result in zero or very small numbers near zero
@Iain Thanks for the effort
I was aware of the division by zero problem, thats why I introduced “small” number in the pseudocode. Handling of the problematic values is one of the things I mentioned above as “a lot of things that would have been corrected to make it work”. I suck at coding.
Now I started to think if negative values are a problem.
If anyone make rawtherapee fork and create an extra demosaicing HBMR code that will compile and work (not necessarily give good results) it would allow me to tinker with it and eventually try all of my ideas.
Only knowing darktable code and how to integrate from my side. Would that also work for you?
@hannoschwalm Thanks for Your offer. Frankly speaking RT would be much easier to me, as there is already my DCB code in there. I could use it as reference. At the same time, I don’t even use DT, not to mention chack it.
FYI here are my results:
Top is green channel with horizontal HBMR
Middle is demosiaced green channel
Bottom is full demosiac.
Honestly, looks better than I thought it would. Thanks for effort and sharing. You did that in Gmic, right?
Yes. I used GMIC.
@Iain Could You share GMIC code and tell me exactly how You use it (GMIC script, or some sort of plugin?). Maybe it will be enough and hacking DT or RT will not be necessary.
I moved this thread to Processing with several tags to improve discovery. Feel free to change them or request changes.
I use GMIC through the GIMP plugin. I have a file called user.gmic that the plugin looks at for my custom filters.
For this task I used a bayer patterned image like this.
This i sthe GMIC code:
#@gui iain_hmbr: iain_hmbr,iain_hmbr(0)
iain_hmbr:
channels[0] 1 #extract green channel
n[0] 0,1 #normalise to range 0-1
+local[0] #create copy of image and apply processing only to the copy
# 'fill' command allows me to do pixel-wise math
fill[0] "
small=0.0001;
p_1=j(-4);
p_2=j(-2);
p_3=i;
p_4=j(2);
p_5=j(4);
if ((p_2-p_4)==0,alpha=0.5*(p_1-p_5)/small,alpha =0.5*(p_1-p_5)/(p_2-p_4));
if(
(alpha < -1),alpha=-1,
if((alpha > 1),alpha=1);
);
alpha=acos(alpha);
if((p_4+p_1-p_2-p_5)==0,omega=(p_4+p_2-p_1-p_5)/small,omega=(p_4+p_2-p_1-p_5)/(p_4+p_1-p_2-p_5)
);
if(((cos(2*alpha)-cos(alpha))==0),omega=omega*(sin(2*alpha)-sin(alpha))/small,omega=omega*(sin(2*alpha)-sin(alpha))/(cos(2*alpha)-cos(alpha)));
omega=atan(omega);
if(((sin(omega-alpha)-sin(omega+alpha))==0),
amp=(p_2-p_4)/small,amp=(p_2-p_4)/(sin(omega-alpha)-sin(omega+alpha))
);
p_0=p_3-amp*sin(omega);
p_0+amp*sin(omega-0.5*alpha-3.14);
" # end of 'fill' command
cut[0] 0,1 #cut image value to range 0-1
shift[0] -1 # shift image one pixel to the left
done # end of 'local'.
# now processing original green channel and processed copy
add # add both images
mul 255 # scale to range expected by the plugin.
@Iain Ok, the plugin works, but I get different result than Yours. I think it is due to some changes made into picture You have sent (above). Could You send it directly to me (send a link i PM or something) and not attach to a post?
Here is the full bayer-patterned tiff file
Here is the original RAW file.
These files are made for testing and research purposes only.