Image Matrix
-
I have written a code which takes the data out of the Matrix for an image and converts from RGB to Y component. My next step would be to split this matrix into 4x4 blocks and perform some calculations. After this, I want to take the resultant matrices and do some computations with the original Matrix. I am confused with the loops and how to go about creating the loops. I will be very glad if someone can help me with a code snippet. Thanks a lot. Sharp
-
I have written a code which takes the data out of the Matrix for an image and converts from RGB to Y component. My next step would be to split this matrix into 4x4 blocks and perform some calculations. After this, I want to take the resultant matrices and do some computations with the original Matrix. I am confused with the loops and how to go about creating the loops. I will be very glad if someone can help me with a code snippet. Thanks a lot. Sharp
-
could you please elaborate your problem, and present it clearly with an example?
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.
-
Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.
still not clear about your question. what is your original matrix size, that you want to sub matricize to 4X4 blocks? i require an example to help you out.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.
you just re-wrote the original question ... not explain.
Watched code never compiles.
-
you just re-wrote the original question ... not explain.
Watched code never compiles.
Ok ... I will try again. I have a matrix of size 128x128. I want to divide this matrix into groups of 4x4 that means the resultant is a matrix of 32x32. The next step is to take an average of this 4x4 matrix, and have the same value for all matrix elements. The resultant will be something like this a b c d e f g h M1=i j k l m n o p M1 is the given matrix. The new matrix M2 is given with the element value q is given by q = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p/16 q q q q q q q q M2=q q q q q q q q And in the next step I want to subtract M2-M1. Would be great if you can help me with a code snippet. Thanks
-
Ok ... I will try again. I have a matrix of size 128x128. I want to divide this matrix into groups of 4x4 that means the resultant is a matrix of 32x32. The next step is to take an average of this 4x4 matrix, and have the same value for all matrix elements. The resultant will be something like this a b c d e f g h M1=i j k l m n o p M1 is the given matrix. The new matrix M2 is given with the element value q is given by q = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p/16 q q q q q q q q M2=q q q q q q q q And in the next step I want to subtract M2-M1. Would be great if you can help me with a code snippet. Thanks
1.if your original matrix of size 128/128 is say "M", 2.write a function as follows
ComputeSubMatrix(int row,int col)
{
int avg=0;
for(int i=row;i'<'row+4;i++)
{
for(int j=col;j'<'col+4;j++)
{
avg+=M[j][i];
}
}
for(i=row;i'<'row+4;i++)
{
for(int j=col;j'<'col+4;j++)
{
M[j][i]=avg-m[j][i];
}
}
}
//Note:please understand '<' as less than symbol .(there is some display problem)3.now, you call this function in nested loops, by passing the start row and column of each sub matrix. 4.and this should solve your problem.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
1.if your original matrix of size 128/128 is say "M", 2.write a function as follows
ComputeSubMatrix(int row,int col)
{
int avg=0;
for(int i=row;i'<'row+4;i++)
{
for(int j=col;j'<'col+4;j++)
{
avg+=M[j][i];
}
}
for(i=row;i'<'row+4;i++)
{
for(int j=col;j'<'col+4;j++)
{
M[j][i]=avg-m[j][i];
}
}
}
//Note:please understand '<' as less than symbol .(there is some display problem)3.now, you call this function in nested loops, by passing the start row and column of each sub matrix. 4.and this should solve your problem.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks
-
In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks
sorry my friend, i ve got to leave for the day now. if i give any short answer, you may again get confused. i have put a mail to your id. keep in touch and we will solve it tomorrow.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks
you need to do something like this.
for(int row=0;row<128;row+=3)
{
for(int col=0;col<128;col+=3)
{
ComputeSubMatrix(row,col);
}
}let me know if you have any doubts.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.