2015-02-26 20:19:42 -0600
| commented question | Grayscale image instead of RGB image Vector[m].at<uchar>(j, i) = (uchar)Sv[i*heigh + j];
Maybe that's right. |
2015-02-24 23:21:46 -0600
| received badge | ● Student
(source)
|
2015-02-24 21:09:37 -0600
| commented question | Grayscale image instead of RGB image I provided code of the function |
2015-02-24 21:09:14 -0600
| received badge | ● Editor
(source)
|
2015-02-23 20:14:10 -0600
| commented question | Grayscale image instead of RGB image I save elments of Mat in uchar vector, and then work with them,when realize LSB. |
2015-02-23 06:47:05 -0600
| commented question | Grayscale image instead of RGB image I realize LSB watermarking algorithm. I load JPEG image,split it to 3 channels,transfer it to unsigned char vector, add watermark, transfer back to 3 one-color Mat and then merge them. Is this plan correct? |
2015-02-23 06:18:01 -0600
| commented question | Grayscale image instead of RGB image It's strange, but it doesn't help:( |
2015-02-15 23:06:51 -0600
| asked a question | Grayscale image instead of RGB image Help me, please. I have 3 color components. When I merging them(function merge()) and then read matrix to image and save them on disk(function imread()), I get grayscale JPEG image instead of color JPEG image. What should I do to get color image? This is all code: string start = "P0ch@t0k";
string finish = "K5k1R9z@";
int allength = start.length() + finish.length() + length;
int* Cypher = new int[allength * 8];//зашифрованный текст в бинарном виде
Cypher = ModVisioner(text, start, finish, length);
string Cyphertext;
for (int i = 0; i < allength; i++)
{
int Temp[8];
for (int j = 0; j < 8; j++)
{
Temp[j] = Cypher[i * 8 + j];
}
Cyphertext.push_back(Binary2Decimal(Temp));
}
cout << Cyphertext << endl;
string Cv;
for (int m = 0; m < 3; m++)
{
for (int i = 0; i < widt; i++)
{
for (int j = 0; j < heigh; j++)
{
Cv.push_back(Matvector[m].at<uchar>(j, i));
}
}
}
string Sv;//вектор изображения с ЦВЗ
vector<int*>v;
for (int m = 0; m < allength; m++)//текст в двоичной форме
{
int* b = new int[8];
for (int i = 0; i < 8; i++)
{
b[i] = Cypher[m * 8 + i];
}
v.push_back(b);
}
for (int i = 0; i < contsize; i++)
{
int* P = new int[8];//замена младшего бита
P = Decimal2Binary((uchar)Cv[i]);
if ((i % 2 == 0) && (i < allength * 2))
{
int k = i / 16;
int l = (i % 16) / 2;
P[7] = v[k][l];
}
else
{
P[7] = rand() % 2;
}
Sv.push_back(Binary2Decimal(P));
}
Mat Vector1(heigh, widt, CV_8UC1);
Mat Vector2(heigh, widt, CV_8UC1);
Mat Vector3(heigh, widt, CV_8UC1);
vector<Mat> Vector;
Vector.push_back(Vector1);
Vector.push_back(Vector2);
Vector.push_back(Vector3);
for (int m = 0; m < 3; m++)
{
for (int i = 0; i < widt; i++)
{
for (int j = 0; j < heigh; j++)
{
Vector[m].at<uchar>(j, i) = Sv[i*heigh + j];
}
}
}
Mat FResult(heigh, widt, CV_8UC3);
merge(Vector, FResult);
imwrite("merged.jpg", FResult);
namedWindow("Display window", WINDOW_AUTOSIZE);
imshow("Display window", FResult);
waitKey(0);
destroyWindow("DisplayWindow");
|
2015-02-05 21:39:27 -0600
| asked a question | SEHException when I want to merge channels in OpenCV This is code: int l = label1->Text->Length;
int* codes = new int[l];
for (int i = 0; i <l; i++)
{
int a = label1->Text[i];
codes[i] = label1->Text[i];
}
System::String^ start = "p0ChAT0K";
System::String^ finish = "J93K@dfa";
System::String^ Result = label1->Text;
length = start->Length + finish->Length + Result->Length;
bool* Cypher = new bool[length * 8];//зашифрованный текст в бинарном виде
if (radioButton2->Checked)
{
Cypher = ModVisioner(codes, start, finish, l);
}
int textsize = length * 8;
int contsize = 3 * widt*heigh;
if (textsize * 2<contsize)//внедрение в каждый второй младший бит
{
label2->Text = "Good Image";
}
else
{
label2->Text = "Bad Image";
}
vector<int>Cv;
for (int m = 0; m < 3; m++)
{
for (int i = 0; i < widt; i++)
{
for (int j = 0; j < heigh; j++)
{
uchar temp1 = Matvector[2 - m].at<uchar>(j, i);
Cv.push_back(temp1);
}
}
}
vector<int>Sv;//вектор изображения с ЦВЗ
vector< bool*>v;
for (int m = 0; m < length; m++)//текст в двоичной форме
{
bool* b = new bool[8];
for (int i = 0; i<8; i++)
{
b[i] = Cypher[m * 8 + i];
}
v.push_back(b);
delete b;
}
for (int i = 0; i < contsize; i++)
{
bool* P = new bool[8];//замена младшего бита
P = Decimal2Binary(Cv[i]);
if ((i % 2 == 0) && (i<length * 2))
{
int k = i / 16;
int l = (i % 16) / 2;
P[7] = v[k][l];
}
else
{
P[7] = rand() % 2;
}
Sv.push_back(Binary2Decimal(P));
delete P;
}
Mat Vector1 = cvCreateMat(heigh, widt, CV_8UC1);
Mat Vector2 = cvCreateMat(heigh, widt, CV_8UC1);
Mat Vector3 = cvCreateMat(heigh, widt, CV_8UC1);
vector<Mat> Vector;
Vector.push_back(Vector1);
Vector.push_back(Vector2);
Vector.push_back(Vector3);
for (int m = 0; m < 3; m++)
{
for (int i = 0; i < widt; i++)
{
for (int j = 0; j < heigh; j++)
{
Vector[2 - m].at<uchar>(j, i) = Sv[i*heigh + j];
}
}
}
Mat FResult = cvCreateMat(heigh, widt, CV_8UC1);
merge(Vector, FResult);//error here
imwrite("merged.jpg", FResult);
return FResult;
It is a code of steganoalgorithm LSB in OpenCV. before merging channels it works well. Please,help me and tell me why this exception is happens. |