View Full Version : convert to immagine in RgB and manipulate
montanaro
18th July 2018, 16:24
Hi
i have to convert immagine jpg into Rgb and convert in grey.
Can you suggest?
montanaro
19th July 2018, 10:10
i can try with for but i dont understand the functions to use.
for example:
QPixmap pix(":/pathFile/NameFile.jpg"); //
//
for (int ii = 0; ii < pix.height(); ii++) {
for (int jj = 0; jj < pix.width(); jj++) {
// qGray(1,1,1);
}
}
Added after 1 41 minutes:
QImage immagine(":/PATH/IMMAGINE.jpg");
QRgb color;
for (int ii = 0; ii < immagine.height(); ii++) {
for (int jj = 0; jj < immagine.width(); jj++) {
color = immagine.pixel(ii,jj);
immagine.setPixel(ii,jj,QColor((qRed(color)*0.3) + qGreen(color)*0.59 + qBlue(color)*0.11).rgb());
}
montanaro
19th July 2018, 13:07
It returned:
QImage::pixel: coordinate (199,822) out of range
Ginsengelf
19th July 2018, 14:50
It returned:
QImage::pixel: coordinate (199,822) out of range
That's because the parameters for immagine.pixel() and setPixel() are in the wrong order.
Ginsengelf
montanaro
19th July 2018, 14:51
That's because the parameters for immagine.pixel() and setPixel() are in the wrong order.
Ginsengelf
yes. thank you.
i corrected.
but the code dont transform immage yet :(
montanaro
23rd July 2018, 09:21
i solvede into Windows:
"
QSize sizeImage = immagine.size();
int width = sizeImage.width(), height = sizeImage.height();
QRgb color;
for (int f1=0; f1<width; f1++) {
for (int f2=0; f2<height; f2++) {
color = immagine.pixel(f1, f2);
// color= immagine.pixel(j,i);
// image.setPixel(f1, f2, QColor((qRed(color) + qGreen(color) + qBlue(color))/3).rgb());
int grigio= qGray(color);
immagine.setPixel(f1,f2, qRgb(grigio, grigio, grigio));
}
}"
but when i use qt on linux virtual machine, it dont run :(
virtual machine says: " conncection refused"
you can suggest ?
montanaro
23rd July 2018, 16:06
i changed ip in qt option and now it runs :D
but now my duty is porting in QML :confused:
how i can? :O
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.