View Single Post
Old 19th March 2017, 06:22   #1  |  Link
moiennepe
Registered User
 
Join Date: Mar 2016
Posts: 2
Edges affected by the background?

Hi all, there is a celluloid animation DVD mpeg2/vob source that looks like:
Y-ch:
The edge on a lighter background has Y value 120~150 (contrast 50+),
and the one on a darker BG has value 30~50 (constract 3~5).

I think this is caused by the "subpixels" (see github.com/Tetrachrome/subpixel). Those edges are actually pure black on the original CEL / printed screenshots.

I wrote some C# code to process them and here's the result:
source:
processed:


Looking for AVS equivalents (especially to grab the dark, low constract ones), or suggestions to improve the code below.



Code:
		
   public static void litas(string ismh)
			{
				byte[] iqmat = File.ReadAllBytes(ismh);
				Array.Copy(iqmat,fariat,720*480+0xF);			
				iqmat=iqmat.Skip(0xF).ToArray();
   //iqmat, kuzn, fariat fyy byte[]
				
			for(int k=2;k<480-2;k++)
			{
				for(int i=2;i<720-2;i++)
				{
					Array.Copy(iqmat,(k-2)*720+i-2,kuzn,0,5);
					Array.Copy(iqmat,(k-1)*720+i-2,kuzn,5,5);
					Array.Copy(iqmat,(k)*720+i-2,kuzn,10,5);
					Array.Copy(iqmat,(k+1)*720+i-2,kuzn,15,5);
					Array.Copy(iqmat,(k+2)*720+i-2,kuzn,20,5);
					byte mithliq = kuzn.Max();
					//Maximum
					
					int ha3al = ((mithliq-iqmat[k*720+i])*1000);
					ha3al/=mithliq;
					//amplified
					
					if(ha3al>255)
						ha3al=255;
					//clamp	
				
					fariat[0xF+k*720+i]= (byte)(255-ha3al); //invert

				}
			}
			
				//TODO
			//========

			for(int k=2;k<480-2;k++)
			{
				for(int i=2;i<720-2;i++)
				{
					Array.Copy(fariat,0xf+(k-2)*720+i-2,kuzn,0,5);
					Array.Copy(fariat,0xf+(k-1)*720+i-2,kuzn,5,5);
					Array.Copy(fariat,0xf+(k)*720+i-2,kuzn,10,5);
					Array.Copy(fariat,0xf+(k+1)*720+i-2,kuzn,15,5);
					Array.Copy(fariat,0xf+(k+2)*720+i-2,kuzn,20,5);
					byte mithliq = kuzn.Min();
					
					if(mithliq>0x70&&iqmat[k*720+i]>0x70)  //120? 60?
							fariat[0xF+k*720+i]=0xff;
					
				}
			}
			//=======
			
			File.WriteAllBytes("haq\\"+ismh,fariat);
			
			}
moiennepe is offline   Reply With Quote