...What I'm hoping is that variables (like X1 thru X17..or an array of variables) could be
substituted for the numerical values in Color Matrix creation code like:
Code:
Dim cMatrix As New ColorMatrix(New Single()() _
{New Single() {0.299, 0.299, 0.299, transp, 0}, _
New Single() {0.587, 0.587, 0.587, 0, 0}, _
New Single() {0.114, 0.114, 0.114, 0, 0}, _
New Single() {0, 0, 0, 0, 0}, _
New Single() {0, 0, 0, 0, 1}})
so that a code sequence of
different "If..Then" structures could test for different booleans like
blnAddAlphaAdjust, blnAddSinusoidalConvolution, blnAddGaussianBlur, etc,
and perform the relevant cumulative additive adjusts on the X1 thru X17 variable number values that are used (in turn) to generate the color matrix.
...
So, are you proposing updating the color matrix (through the use of the variables) for each pixel being drawn (i.e. draw pixel, modify matrix, draw pixel, modify matrix, ...)?
A color matrix can only self-reference one pixel's components, transform them to other values based on the contents of the matrix, and then return the resulting color. One color in, one color out.
The rendering of the pixel (how the resulting color is combined with the destination pixel) is still the simple alpha based combination of the two colors inherent in ARGB bitmap drawing which takes place after the source color has been transformed.
Most of your filters and noise generators are going to involve more than one pixel.
The color matrix can't be used to take one bitmap as a reference to modify another.
The texturing example you have is not merging pixels from the two bitmaps. It is transforming the source pixel on the fly to grayscale and using the grayscale value to modify the alpha as well. The resulting pixel color is then just normal ARGB'ly combined with the destination pixel.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
So, are you proposing updating the color matrix (through the use of the variables) for each pixel being drawn (i.e. draw pixel, modify matrix, draw pixel, modify matrix, ...)?
It wasn't necessarily something I was going to try, but I did wonder if something like that might be possible..
Quote:
Most of your filters and noise generators are going to involve more than one pixel.
The color matrix can't be used to take one bitmap as a reference to modify another.
That was I was afraid of..I wanted to be able to use a color matrix for effects whenever I can
but this is obvious the "wall" that is going to limit the use of a color matrix in some cases.
That is why I'm going to keep working with the FastPix library.
It makes a good wrapper for Lock/UnLock bits,
and there are still a lot of VB.Net code examples I have found on the internet
that rely on GetPixel/SetPixel.
Using the FastPix code makes for an easy substitution.
A little progress - towards a pixel differentiator and adjusting framework
The attached code works well in detecting the differences between the
background-only picturebox image and the
background with fuzzy lines overlay picturebox image.
That's the good part.
The bad (ugly) part is what happens when the code tries to create an alpha mask.
Its creates something..I just don't think its really a true (real) alpha mask.
I should be able to change this line
Code:
'bytDifference represents a changing alpha value determined at runtime
Dim newColor3 As Color = Color.FromArgb((bytDifference), 128, 128, 128)
to use white instead of grey:
Code:
'bytDifference represents a changing alpha value determined at runtime
Dim newColor3 As Color = Color.FromArgb((bytDifference), 255, 255, 255)
..and have some assemblance of greyscale gradients (using varying alpha values),
but it just ends up creating a jagged (ragged) group of pure colored pixels.
Anyway, at this point I'm having more of a conceptual (rather than a coding) breakdown.
What I'm trying to develop (evolve) is the code to create is a fuzzy lines shaped mask
that I can use not just with a pure color (like white),
but as a more general alpha opacity per pixel gradient mask,
in conjunction with a texture graphic,
(like a stone texture, wood grain, or parchment).
There aren't any internet samples of making up a per pixel alpha mask by determining
differences between two pics that I have been able to find,
so I'm just trial and error coding at this point
(don't ask what happened with versions 1-6).
Alpha mask creation for pixel splattered multi-level transprency lines
Well it's been a few days and it doesn't look like anyone is interested in viewing the attachment from my last post.
Maybe everyone (including passel) thinks this thread is dead but it is not.
I'm wondering if doing a colormatrix greyscaling before trying to create the mask would help things out any..
Quote:
edit: I'm also thinking that the alpha value should remain steady at 255 while
the individual RGB values should each reflect pixel color value differences.
So using the blue "channel" to create a greyscale mask,
the code might look like:
'Excerpted from inside x,y looping (using multiple FastPix LockBits wrappers)
'Assigning images..
image1 = New Bitmap(CType(PictureBox1.Image, Bitmap))
image2 = New Bitmap(CType(PictureBox2.Image, Bitmap))
bmpMask = New Bitmap(CType(picMask.Image, Bitmap))
Dim x, y As Integer
Using fp1 As New FastPix(image1)
Using fp2 As New FastPix(image2)
Using fp3 As New FastPix(bmpMask)
'Calculating blue color difference
Dim bytDifference As Byte, bytBlue1 As Byte, bytBlue2 As Byte
bytBlue1 = pixelColor1.B
bytBlue2 = pixelColor2.B
If bytBlue1 > bytBlue2 Then
bytDifference = (bytBlue1 - bytBlue2)
Else
bytDifference = (bytBlue2 - bytBlue1)
End If
'Setting mask pixels
Dim newColor3 As Color = Color.FromArgb(255, bytDifference, bytDifference, bytDifference)
fp3.SetPixel(x, y, newColor3)
End Using
End Using
End Using
I have to try this once I get the color matrix greyscaling module added on..
Thread resolved - with an example of applying a procedurally created alpha mask
Well, its been over a week and my last attachment got one view,
(hopefully it was passel).
The secret wasn't greyscaling but using the manipulating the rgb values directly instead
of using the greyscale value as the alpha value of the bitmap's ARGB pixel values.
Anyway, check out the two screenshots.
One is using an alpha mask to create a tint with a single color
(the tinting color can be adjusted at runtime).
The other shows doing per pixel alpha blending of a procedurally generated texture (random pixels).
Using the FastPix code as a lock / unlock bits wrapper for GetPixe / SetPixel)
the speed is such that one could even imagine
doing a real time animation with double alpha masking.
The attached code represents the closest I have been able to come up with
toward replicating the same functionalities using VB.Net.
Besides the demo for the real time double alpha masking,
I have also developed a nice set of routines for creating different types of
"splatter" pixel graphics, but I guess I'll just end this thread here.
If passel isn't interested in posting anymore (as much as he is interested in graphics)
than the subject of this thread is probably a bit to esoteric for anyone else
(too bad).
I believe the ability to do sophisticated per pixel manipulation has the potential
to achieve some very interesting animated graphic effects achievable in no other way.
However the system.drawing,drawing.drawing2d class has very few built-in
code routines
for doing different types of per pixel effects, so it looks like non-Micorosft employees,
(i.e. members of the VB.Net community-at-large),
will have to "patch" the .Net framework and create their own such code routines.
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET. subscribe