Hi to all of you my friends. First of all , i already know java so i think i'll stick to that but anyways. I'm creating a facial recognition program and I'm just starting with opencv. I'm learning the Class "Mat" and what it means, here's the definition.
The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms.
I'm trying to learn what a single-channel or multi-channel array mean but i can't find information online for whatever reason. Can you explain this concept to me maybe linking some useful websites?
Thank you, Mattia (aka DJack)
single-channel or multi-channel can be understood by simple daily life examples.
Suppose you have two rectangular-shaped slices of bread.
Put the first bread on the floor in a vertical way(standing bread on the side).
And look from the top, the thing you will find is the single channel.
again, put the second piece of bread in the same way but parallel to the first bread ( parallel in the horizontal plane).
Now again look from the top, you will see two pieces of bread this time, this represents 2 channel matrix.
click on this link to see an image which is a 3 channel matrix
This is a 3 channel 8 bit unsigned integer.
This array consists of tuples with 3 elements.
For example :
{54,0.34} - first tuple
{58,78,185} - second tuple and so on.
but in the single channel matrix, you will get only one element. like 58, 78 etc.
Directly from the comment by #Dan Mašek solves your problem:
Number of channels means:
how many values are used to represent a single element (e.g. pixel in a picture). For example, grayscale image represents each pixel by 1 value (intensity), so it will be stored as a single channel Mat. RGB image needs 3 values (red, green and blue), hence it needs a 3 channel Mat. RGBA has 4 values per pixel, so 4 channel image.
Related
I'm trying to draw a sinus wave-form (think Siri) that picks up and is immediately influenced by a user's voice. If I could accomplish exactly this in Android with as much fluidity on a device such as the S4, I will be extremely satisfied, so any helpful information is greatly appreciated.
Right now, I understand how to use the MediaRecorder to grab the max amplitude at a "tick" (reference), and I can store several of these integer values in an array as the MediaRecorder is recording and picking up audio, but I have no idea how I can transform this array of integers into something like the Github project that I posted above. I'd also appreciate if someone could suggest how large this array should be, since I want to dump old data as quickly as possible to make the animation fast and use as little memory as possible.
EMy aproach would be as follows: You could store, say, the last 5 values (In your example, it shows about 5-6 lines at a time).
Then, for each value in these 5 values:
Take the max amplitude value you can get for reference, and use it for calculate a percentage of the current value. Use that percentage along with the sin(x)Math.sin function to smooth the curvy line:
example:
MAX_AMPL:1200
CURR_VALUE: 240 -->20% of MAX_AMPL
Use android drawing primitives Drwaing on android to draw f(x)=(CURR_VALUE/MAX_VALUE) Math.Sin (x)
If you draw the function between 0 and 2Pi i think you will get the same number of waves as in your example.
The more recent the value (position in value ArrayList), the more wider the line for vanishing efect.
Last, draw your graphs from the oldest to the newer.
I need to write tests (in Java) for an image capturing application. To be more precise:
Some image is captured from a scanner.
The application returns a JPEG of this image.
The test shall compare the scanned image with a reference image. This reference image has been captured by the identical application and has been verified visually that it contains the same content.
My first idea was comparing the images pixel by pixel but as the application applies a JPG compression the result would never by "100 % identical". Besides the fact that the scanner would capture the image with slight differences each time.
The goal is not to compare two "random images" for similarity like "Do both images show a car?" but rather "How similar is the captured car to the reference image of this car?".
What other possibilities do you see?
Let me say first, that image processing is not my best field, nor am I an expert in any way. However, here is my suggestion: take the absolute value of each pixel in the pictures, in row-major order, respective to each other. Then, average out the differences, and see if the average is within a certain threshold: if so, the images are similar in nature. Another way, would be to go once more pixel by pixel, but instead count the number of pixels that differ by at least x, where x is a number chosen to represent how close the matching needs to be. Then, just see if the different pixels comprise 5% of all pixels, 10%, and so on. The more pixels, the more different the image.
I hope this helps you, and best of luck.P.S. to judge how far two pixels are apart, it's going to be like finding the distance between two points (i.e. sqrt[(r2-r1)^2+(g2-g1)^2+(b2-b1)^2]).P.P.S. This all of course assumes that you listened to the Hovercraft Full of Eels, and have somehow made sure that the images match up in size and position.
This question already has answers here:
Java Program using 4D array [closed]
(8 answers)
Closed 9 years ago.
I have been studying Java and C++ this year, and I am wondering; what practical uses are there for a 4 or even 5 dimensional array? My teacher basically says that you are using the wrong datatype if you want to use a 4 dimensional array.
Have you ever used a 4 of 5 (or more) dimensional array? What did you use it for? What practical uses can you think of for them?
Thanks!
A practical use of a 4D array is to keep track of a 3d object, could keep track of [x-cord][y-cord][z-cord][time]. This 4D array would be a useful use of a 4D array. This could keep track of a range of cords and time, and the value in the array could say the speed of of the object.
Speed = arr[5][9][6][1500];
That would record the speed of the object when it was at x cord 5, y cord 9, z cord 6, and say been alive for 1500 seconds.
As for your 5D array:
int left; //#of cars left in world
left = allCars[year][brand][color][condition][horsepower];
brand count be an int(have a table of values aka Ferrari = 1, same with color. Condition could be on a scale of 0 being destroyed, to 1 being brand new).
Then you could find the # of 1947 Ferrari's that are red in brand new condition with 200 horsepower.
Aka in general you could use many dimensional arrays to keep track of large databases of things.
You may create a Sodoku hypercube with 4 dimensions and then you can store the number which the user enters into a 4dimensional int array.
Rotating 4D hypercube (GIF movie). Imagine a person who lives in 4
spatial dimensions, watching a hypercube rotate. The 4-dimensional
person has a 3-dimensional retina in each of its 2 eyes (two eyes
suffice for depth perception, even in 4D). Each retina records a
3-dimensional image.
This image shows what the 4-dimensional person sees, with the extra
dimension shown as a variation in colour. That is, the horizontal,
vertical, and `colour' directions correspond to the 3 directions on
the 3-dimensional retina of the 4-dimensional person. The vertical bar
to the right of the picture shows the correspondence between colour
and position in the extra dimension.
Also you may check the Tesseract
Take almost anything from physics, where tensors are common, for example general relativity, computational chemistry, quantum physics.
http://en.wikipedia.org/wiki/Tensor#Applications
Tensor with rank 4 is common for example.
http://www.oonumerics.org/FTensor/FTensor.pdf
http://mpqc.svn.sourceforge.net/viewvc/mpqc/trunk/mpqc/src/lib/chemistry/qc/lmp2/lmp2.cc?revision=9342&view=markup&pathrev=9492
The example was a stock-keeping system where jeans could be indexed by
inventory[size][length][color][fit] = number_received
which is only slightly contrived. You'd have no problem with a database structured in such a way but it does look funny as code.
You might be running a geophysics simulation, where you have a 3D region such as an oil field, and you are measuring the relative quantities of different substances found at different points in the region (oil, water, sand, porous rock and so on). You might have three dimensions for the position, and one dimension for which substance you're looking at.
I am using a BufferedImage to hold a 10 by 10 sample of an image. With this Image I would like to find an approximate average color (as a Color object) that represents this image. Currently I have two ideas on how to implement this feature:
Make a scaled instance of the image into a 1 by 1 size image and find the color of the newly created image as the average color
Use two for loops. The inner-most is used to average each line, the secondary for-loop is used to average each line pixel by pixel.
I really like the idea of the first solution, however I am not sure how accurate it would be. The second solution would be as accurate as they come, however it seems incredibly tedious. I also believe the getColor command is processor intensive on a large scale such as this (I am performing this averaging roughly at 640 to 1920 times a second), please correct me if I am wrong. Since this method will be very CPU intensive, I would like to use a fairly efficient algorithm.
It depends what you mean by average. If you have half the pixels red and half the pixels blue, would the average be purple? In that case I think you can try adding all the values up and dividing it by how many pixels you have.
However, I suspect that rather than the average, you want the dominant colour?
In that case one alternative could be to discretise the colours into 'buckets' (say at intervals of 100, or even more sparser in the extreme case just 3, one for Red, one for Green and one for Blue), and create a histogram (a simple array with counts). You would then take the bucket which has the most count.
Be careful with idea 1. Remember that scaling often takes place by sampling. Since you have a very small image, you have already lost a lot of information. Scaling down further will probably just sample a few pixels and not really average all of them. Better check what algorithm your scaling process is using.
In weka I load an arff file. I can view the relationship between attributes using the visualize tab.
However I can't understand the meaning of the jitter slider. What is its purpose?
You can find the answer in the mailing list archives:
The jitter function in the Visualize panel just adds artificial random
noise to the coordinates of the plotted points in order to spread the
data out a bit (so that you can see points that might have been
obscured by others).
I don't know weka, but generally jitter is a term for the variation of a periodic signal to some reference interval. I'm guessing the slider allows you to set some range or threshold below which data points are treated as being regular, or to modify the output to introduce some variation. The wikipedia entry can give you some background.
Update: from this pdf, the jitter slider is for this purpose:
“Jitter” option to deal with nominal attributes (and to detect “hidden”data points)
Based on the accompanying slide it looks like it introduces some variation in the visualisation, perhaps to show when two data points overlap.
Update 2: This google books extract (to Data mining By Ian H. Witten, Eibe Frank) seems to confirm my guess:
[jitter] is a random displacement applied to X and Y values to separate points that lie on top of one another. Without jitter, 1000 instances at the same data point would look just the same as 1 instance
I don't know the products you mention, but jittering generally means randomising the sample positions. Eg, in ray tracing you would normally render a ray though each pixel on the screen. Jittering adds a random offset to each ray to reduce issues caused by regular aliasing.