Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
16th March 2005, 19:34 | #1 | Link |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Averaging pixels (by downsizing image?) - solved
*********************EDIT:
If you happen to need average pixel like this, look directly at posts 17th March 2005 00:29 27th March 2005 21:47 There is also a function ShrinkBy2 in SSETools plugin which "sounds" like it could work, but I didn't check and AFAIK no docs are available. ********************** Hi, I want to make average of each block of 4x4 pixels (in YV12) on mod4 sized clip. I thought a way is via downsizing. More exactly, when I have block like this (numbers are colors) 0011 0011 4433 4433 I want to get 2222 2222 2222 2222 etc. Via downsizing it would be 22 22 and then PointResize back to original size. But I never achieved it. I tried different resizers.. these aliasing or sharpening or whatever effects cause sometimes result like this: 0000 0000 0000 0000 into 11 11 when there was some value in nearby block. Similar for 8x8. Thanx R. Last edited by redfordxx; 1st April 2005 at 13:58. |
16th March 2005, 22:01 | #3 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
average of colors of the four relevant pixels of original clip, which were merged by downsizing. |
|
16th March 2005, 23:12 | #5 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
YV12 The same priciple as for Y sould work for U,V --- only doublesized |
|
16th March 2005, 23:58 | #7 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
Look (I'm testing it only in one channel, so don't be scared by the color) the second one is with higher contrast, to see the difference. Just try swithing the images fast. You will easily find blocks on the second pic, where the same block on first image is 100% clear. E.g. top left one and the one below... |
|
17th March 2005, 01:05 | #9 | Link |
Simply me
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
|
Just to fully clarify - do you want this
A B W X C D Y Z J K P Q L M R S made into E E V V E E V V I I N N I I N N Where E is Average(A,B,C,D), V= Average(W,X,Y,Z) etc or something else regards Simon
__________________
http://www.geocities.com/siwalters_uk/fnews.html |
17th March 2005, 01:18 | #11 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
|
|
17th March 2005, 01:29 | #13 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
DEdgeMask(0,255,0,255,"0 0 0 0 1 1 0 1 1",U=3,V=3).PointResize(50%).PointResize(100%)
Not sure which points actually are taken by PointResize, though. Eventually the kernel has to be flipped u/d or l/r.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
17th March 2005, 11:45 | #15 | Link | |
Registered User
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
|
Quote:
Well, honestly, I didn't expect the solution is so complicated... (I mean the idea is nice. Probably more CPU time demanding than I thought...) Kernel=the matrix in "", isn't it? Last edited by redfordxx; 17th March 2005 at 11:49. |
|
17th March 2005, 12:19 | #18 | Link | ||
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Manao: Good moaning, erh, morning ...
Quote:
Basically, BilinearResize would do the very same thing. But if it were coded so as to average every 2*2 pixels (as you need here), then the resizer would shift the frame around during downsizing+upsizing combos. For a resizer, that's of course not acceptable. Quote:
Code:
1 2 3 4 5 6 7 8 9 DCFilter(1,0,0,0,0,0,0,0)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
||
17th March 2005, 12:29 | #19 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
> BilinearResize would do the very same thing.
No, and that's why I deleted my post : when downsizing by a factor two, the bilinear algorithm takes 4 pixels into accounts ( weighting them 0.25 0.75 0.75 0.25 ). When upsizing, however, it takes only two pixels into account ( 0.5 0.5 ), so the following : Bilinearresize(double_width, double_height).pointresize(half_width, half_height).pointresize(width, height) Should give a similar result to your script ( there again, we don't know which pixel is used by pointresize, and an offset is needed ) BTW, Didee, you often use DEgdeMask where i'd use YV12Convolution, especially when i'm not building a mask. |
17th March 2005, 12:39 | #20 | Link | |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Ah, yes. Thanks for the correction on the bilinear thingie.
Quote:
Code:
1 1 1 2 3 2 -1 -1 -1 1 0 0 1 0 1 3 2 3 -1 9 -1 0 1 0 1 1 1 2 3 2 -1 -1 -1 0 0 1 But of course here you're right: In this case, on could as well use yv12convolution("0 1 1","0 1 1") Mind I was pretty tired as well when writing that post above
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|