Hi,
erst mal wünsch ich einen schönen Feiertag.
Ich hab ein Problem mit folgender aufgabe:
Ich soll ein Tool schreiben das mir ein beliebig großes (Länge, Bereite) Bild in ein anderes Bild Mapt. das dann ein Kreis wird. Quasi wird das bild so umgemapt das ein Kreis daraus entsteht.
z.B: Ich hab ein Bild mit einem Karomuster drauf dann soll ein Bild mit einem Spinnennetz dabei raus kommen.
Dafür hab ich eine tolle funktion aus der Doku:
http://www.intel.com/software/products/ ... ppmman.pdf
Seite 775;
Ich hab schon mit diesen Funktionen gearbeitet!
Mein Problem ist jetzt das diese Funkton 2 Arrays mit spezielen Daten hat die Ungefähr doubel Werten entsprechen für alle X-Pos Ziel Bilds und alle Y-Pos des Zielbilds und da kommen dann die Angaben zum Original Bild rein. Und da liegt bei mir der Punkt an dem ich vom Ansatz her scheiter.
Weil: Im Quellbild ist 0,0 oben Links. Das Wird im Zielbild width / 2, height / 2 sein.
Soweit so gut nur muss das Zielbild beliebig größenverstellbar sein. Also brauch ich einen Ansatz für eine bzw. Mehrere Schleifen die mir unabhänig von den Werten die Punkte Remapn.
Ich hoffe ich hab das so verständlich ausgedrückt. Im Prinzip soll aus einem Bild ein 2tes Bild werden das einen Kreis enthält und in dem Kreis ist das Orginal Bild reingemapt.
Ich wäre für jede art von Ansatz super dankbar.... weil das Prinzip hab ich glaub ich noch nicht so ganz verstanden.
Hier mal meine Ansätze:
- Werte für width und heigth setzen.
- Dann Größe des Bilds errechnen (Multipliziernen)
- Den Mittelpunkt auf hälfte hälfte setzen und einen Umkreis berechnen von der Kleineren größe.
- Alle anderen Punkte(Pixel) im Kreis berechnen.
_______________________________________________
Hoffe jemand kann mir da bisschen weiterhelfen oder meinen Knoten auflösen.
Trotzdem schon mal vielen Dank.
PS: Wenn ichs nicht verständlich geschrieben habe dann etschuldige ich mich nur Fragen und ich versuche es besser zu erklären
Gruß
Qt-nator
Hilfe bei Verformungstool
Oh stimmt die Internet Doku hat ja echt weniger seiten.. garnicht gesehn.
Ich poste Mal die Funktion.
//Aufbau
IppStatus ippiRemap_<mod>(const Ipp<datatype>* pSrc, IppiSize srcSize,
int srcStep, IppiRect srcRoi, const Ipp32f* pxMap, int xMapStep,
const Ipp32f* pyMap, int yMapStep, Ipp<datatype>* pDst, int dstStep,
IppiSize dstRoiSize, int interpolation);
Das Problem ist halt meine Doku ist ein 13 MB großes PDF... kann ich ned hochladen auf meine Seite.
Aber die Funktion ist nicht das Problem sondern wie ich die Pixel neu Setze
Das sind die 2 Mir sorgen machenden Parameter:
pxMap, pyMap
Pointers to the starts of 2D buffers, containing tables of the x- and
y-coordinates. If the referenced coordinates correspond to a pixel
outside of the source ROI, no mapping of the source pixel is done.
xMapStep, yMapStep
Steps in bytes through the buffers containing tables of the x- and
y-coordinates.
Hoffe es hilft
Ich poste Mal die Funktion.
//Aufbau
IppStatus ippiRemap_<mod>(const Ipp<datatype>* pSrc, IppiSize srcSize,
int srcStep, IppiRect srcRoi, const Ipp32f* pxMap, int xMapStep,
const Ipp32f* pyMap, int yMapStep, Ipp<datatype>* pDst, int dstStep,
IppiSize dstRoiSize, int interpolation);
Das Problem ist halt meine Doku ist ein 13 MB großes PDF... kann ich ned hochladen auf meine Seite.
Aber die Funktion ist nicht das Problem sondern wie ich die Pixel neu Setze
Das sind die 2 Mir sorgen machenden Parameter:
pxMap, pyMap
Pointers to the starts of 2D buffers, containing tables of the x- and
y-coordinates. If the referenced coordinates correspond to a pixel
outside of the source ROI, no mapping of the source pixel is done.
xMapStep, yMapStep
Steps in bytes through the buffers containing tables of the x- and
y-coordinates.
Hoffe es hilft
Hier mal mein versuchter Anfang:
Edit: Das die Neue Version. Da fehlt jetzt nur noch die Befüllung der 2 Arrays pxMap und pyMap wo die Parameter Oben erklärt sind.
Wenn da jemand eine Idee hat nur zu. Also Quell Img in einen Kreis im Ziel Img.
Wenn was negatives auffällt bitte sagen
Code: Alles auswählen
#include <ipp.h>
#include <ippdefs.h>
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString strFileName = QFileDialog::getOpenFileName(0, ("Open File"), QDir::currentPath(),"Images (*.png *.jpg *.bmp)");
if (!strFileName.isEmpty())
{
QImage imgLoadImage(strFileName);
int dWidthDst = 500;
int dHeightDst = 1000;
QImage imgResult(dWidthDst, dHeightDst, QImage::Format_RGB32);
if(strFileName.endsWith(".bmp", Qt::CaseInsensitive))
{
strFileName.remove(strFileName.size() - 4, 4);
}
else if(strFileName.endsWith(".jpg", Qt::CaseInsensitive))
{
strFileName.remove(strFileName.size() - 4, 4);
}
else if(strFileName.endsWith(".png", Qt::CaseInsensitive))
{
strFileName.remove(strFileName.size() - 4, 4);
}
int nInterpolation = IPPI_INTER_CUBIC;
IppiSize srcSize;
srcSize.width = imgLoadImage.width();
srcSize.height = imgLoadImage.height();
//Dst Region of Interest Size
IppiSize dstRoiSize;
dstRoiSize.width = dWidthDst;
dstRoiSize.height = dHeightDst;
//Region of Interest Quelle
IppiRect srcRoi;
srcRoi.x = 0;
srcRoi.y = 0;
srcRoi.width = imgLoadImage.width();
srcRoi.height = imgLoadImage.height();
//Region of Interest Ziel
IppiRect dstRoi;
dstRoi.x = 0;
dstRoi.y = 0;
dstRoi.width = imgResult.width();
dstRoi.height = imgResult.height();
//Stepweite der Pixel
int dstStep = imgResult.width() * 4;
int srcStep = imgLoadImage.width() * 4;
//Pointer zu dem Quellbild
uchar *pSrc;
pSrc = imgLoadImage.bits();
//Pointer zum Ziel Bild
uchar *pDst;
pDst = imgResult.bits();
//pxMap // xMapStep
int xMapStep = 10;
Ipp32f *pxMap = new Ipp32f[dWidthDst*dHeightDst];
//pyMap // yMapStep
int yMapStep = 10;
Ipp32f *pyMap = new Ipp32f[dWidthDst*dHeightDst];
for(int i=0; i < dWidthDst; i++)
{
for (int j = 0; j < imgLoadImage.width(); j++)
{
pxMap[i] = j;
}
}
for(int i=0; i < dHeightDst; i++)
{
for(int j = 0; j < imgLoadImage.width(); j++)
{
pyMap[i] = j;
}
}
ippiRemap_8u_C4R(pSrc, srcSize, srcStep, srcRoi, pxMap, xMapStep, pyMap, yMapStep, pDst, dstStep, dstRoiSize, nInterpolation);
imgResult.save(strFileName + "sw.png", "PNG");
return 0;
}
}
Wenn da jemand eine Idee hat nur zu. Also Quell Img in einen Kreis im Ziel Img.
Wenn was negatives auffällt bitte sagen