1 / 26

Softwaretechnologie für Fortgeschrittene Teil Thaller Stunde III: Bildverarbeitung III

Softwaretechnologie für Fortgeschrittene Teil Thaller Stunde III: Bildverarbeitung III. Köln 6. Dezember 2012. Nachbarschaftstransformationen. Basisvorgehen: for (int y=1;y<result.height()-1;y++) { baseline=image.scanLine(y); for (int x=1;x<result.width()-1;x++)

murphy-rice
Download Presentation

Softwaretechnologie für Fortgeschrittene Teil Thaller Stunde III: Bildverarbeitung III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Softwaretechnologie für FortgeschritteneTeil ThallerStunde III: Bildverarbeitung III Köln 6. Dezember 2012

  2. Nachbarschaftstransformationen Basisvorgehen: for (int y=1;y<result.height()-1;y++) { baseline=image.scanLine(y); for (int x=1;x<result.width()-1;x++) *(result.scanLine(y) + x) = TIneighbour8(image,x,type,baseline); }

  3. Nachbarschaftstransformationen Beispiel für eine Nachbarschaftstransformation: static int Xoffset[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1}; static int Yoffset[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1}; width=image.width(); switch(action) { case TINMinimum: result=255; for (int i=0;i < 9; i++) { candidate = *(baseline + (width*Yoffset[i]) + x + Xoffset[i]); if (candidate < result) result=candidate; } break;

  4. Nachbarschaftstransformationen Hervorheben von Intensitätsänderungen – X Differenz for (int y=0;y<result.height();y++) for (int x=1;x<result.width();x++) { collect = *(image.scanLine(y) + x) – *(image.scanLine(y) + x-1); *(result.scanLine(y) + x) = (collect<0) ? collect * -1 : collect; }

  5. Nachbarschaftstransformationen NB: Partielle Transformationen können in Bilder „eingeschrieben“ werden – Übergangsbetonung durch Einrechnen XY Differenz: step1=TIcontrastS(TIXYdifference(image)); for (int y=0;y<result.height();y++) for (int x=0;x<result.width();x++) *(result.scanLine(y) + x) = (*(step1.scanLine(y) + x) >= 128) ? 0 : *(image.scanLine(y) + x);

  6. Filteroperationen : Nachbarschaften Auf der operativen – nicht mathematischen – Ebene können Filter als multiplikative Nachbarschaftstransformationen verstanden werden.

  7. Filteroperationen : Nachbarschaften Filteranwendung 1 / 2: static int filter[4][9]= { 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 = low pass 1 */ 0, 1, 0, 1, 1, 1, 0, 1, 0, /* 1 = low pass 2 */ 0,-1, 0,-1, 5,-1, 0,-1, 0, /* 2 = high pass 1 */ -1,-1,-1,-1, 9,-1,-1,-1,-1 /* 3 = high pass 2 */ }; static int divisor[4] = {9,5,1,1}; unsigned char *baseline; for (int y=1;y<result.height()-1;y++) { baseline=image.scanLine(y); for (int x=1;x<result.width()-1;x++) *(result.scanLine(y) + x) = TIfilter8(image,x,filter[type],divisor[type],baseline);

  8. Filteroperationen : Nachbarschaften Wobei gilt (Filteranwendung 2 / 2): int Xoffset[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1}; int Yoffset[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1}; width=image.width(); collect=0; for (int i=0;i < 9; i++) collect += *(baseline + (width*Yoffset[i]) + x + Xoffset[i]) *filter[i]; result = collect / divisor;

  9. Filter: Dementsprechend, die wichtigsten Filter: static int filter[15][9]= { 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0 = low pass 1 */ 0, 1, 0, 1, 1, 1, 0, 1, 0, /* 1 = low pass 2 */ 0,-1, 0,-1, 5,-1, 0,-1, 0, /* 2 = high pass 1 */ -1,-1,-1,-1, 9,-1,-1,-1,-1, /* 3 = high pass 2 */ 1, 2, 1, 2, 4, 2, 1, 2, 1, /* 4 = W.Mean 1 */ 0, 1, 0, 1, 2, 1, 0, 1, 0, /* 5 = W.Mean 2 */ 0, 1, 0, 1,-4, 1, 0, 1, 0, /* 6 = Laplace 1 */ -1,-1,-1,-1, 8,-1,-1,-1,-1, /* 7 = Laplace 2 */ 0,-1, 0,-1, 7,-1, 0,-1, 0, /* 8 = Laplace 3 */ -1,-1,-1, 0, 0, 0, 1, 1, 1, /* 9 = Prewitt A */ -1, 0, 0, 0, 0, 0, 0, 0, 1, /* 10 = Roberts A */ -1,-2,-1, 0, 0, 0, 1, 2, 1, /* 11 = Sobel A */ 1, 0,-1, 1, 0,-1, 1, 0,-1, /* 12 = Prewitt B */ 0, 0,-1, 0, 0, 0, 1, 0, 0, /* 13 = Roberts B */ -1, 0, 1,-2, 0, 2,-1, 0, 1 /* 14 = Sobel B */ }; static int divisor[15] = {9,5,1,1,16,6,1,1,3,1,1,1,1,1,1}; static int absolute[15] = {0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1};

  10. Transformationen des Fourier Typs Prinzip: Die Zuordnung von Helligkeitswerten zu Punkten wird durch eine andere geometrisch / mathematische Interpretation derselben numerischen Werte ersetzt. Fourier: Die räumliche Verteilung von Helligkeitswerten kann durch eine Bündelung von Frequenzwerten ersetzt werden.

  11. Transformationen des Fourier Typs Beispielsweise ist leicht nachvollziehbar, dass im Bild jede Zeile des Bildes auch als eine „Schwingung“ verstanden werden kann, deren „hohe“ Amplitude besonders „hell“, deren „niedrige“ besonders „dunkel“ ist.

  12. Transformationen des Fourier Typs Wenn dies so ist, kann dieses Bild offensichtlich durch Angabe der Schwingungsdauer und der Amplitude dargestellt werden. Wird dies weitergedacht, kann man konzeptuell jeden Punkt eines Punktes dadurch beschreiben, dass man behauptet, das Bild von n x m Pixeln stelle n x m Schwingungen dar, von denen jede an genau einem der Pixel jene Ausprägung der Amplitude habe, die dem Helligkeitswert dieses Pixels entspräche.

  13. Transformationen des Fourier Typs Fouriertransformationen sind relativ anspruchsvoll effektiv zu optimieren; werden deshalb NICHT im Quellcode besprochen. Sie sind aber EXTREM wichtig. Wichtig ist, folgende Eigenschaften festzuhalten:

  14. Transformationen des Fourier Typs (1) Fouriertransformationen sind voll umkehrbar:

  15. Transformationen des Fourier Typs (2) Transformierte Bilder können zielgerichtet bearbeitet werden:

  16. Transformationen des Fourier Typs (2) Transformierte Bilder bestehen üblicherweise aus überwiegend sehr viel kleineren Zahlenwerten:

  17. II. Bildspeicherung und Kompression Techniken zum Transfer von Bytestreams aus der linearen Form (Platte) in strukturierte Form (Memory).

  18. Binäres Lesen (Qt flavour) „Lesen“ imageFile.seek(ifd_addr); imageFile.read((char *)buffer,n); „Schreiben“ imageFile.seek(ifd_addr); imageFile.write((char *)buffer,n); „Position merken“ ifdstart = imageFile.pos();

  19. Komprimieren Run Length Encoding while(line > 0) { c = *(source)++; if (c < 0) { count = c * -1 + 1; memset(target, *source, count); source++; } else { count = c + 1; memcpy(target, source, count); source += count; } line -= count; target += count; }

  20. Komprimieren CCITT / Huffmann Encoding (bitonal) 1 / 3 while(gotten<header->width) { if ((runlength=TIfetchrun(&ccitt,buffer,0,&err))<0) goto cleanup; memset(target,usecolor[0],runlength); target+=runlength; gotten+=runlength; if (gotten>=header->width) break; if ((runlength=TIfetchrun(&ccitt,buffer,1,&err))<0) goto cleanup; memset(target,usecolor[1],runlength); target+=runlength; gotten+=runlength; }

  21. Komprimieren CCITT / Huffmann Encoding (bitonal) 2 / 3

  22. Komprimieren CCITT / Huffmann Encoding (bitonal) 3 / 3

  23. Komprimieren Lempel-Ziv & Welch (LZW) 1 / 2 InitializeStringTable(); WriteCode(ClearCode); W = the empty string; for each character in the strip { K = GetNextCharacter(); if W+K is in the string table { W = W+K; /* string concatenation */ } else { WriteCode (CodeFromString(W)); AddTableEntry(W+K); W = K; } } WriteCode (CodeFromString(W)); WriteCode (EndOfInformation);

  24. Komprimieren Lempel-Ziv & Welch (LZW) 2 / 2 static int shifts[4][8] = { 7, 6, 5, 4, 3, 2, 1, 0, 14, 13, 12, 11, 10, 9, 8, 7, 13, 12, 11, 10, 9, 8, 7, 6, 12, 11, 10, 9, 8, 7, 6, 5 }; int raw, use; use = lzw->lzwbits >> 3; if (use >=max) return TiffLZWEOI; raw = (raster[use] << 8) + (raster[use + 1]); if (lzw->lzwcs>9) raw= (raw<<8) + (raster[use + 2]); raw >>= shifts[lzw->lzwcs-9][lzw->lzwbits % 8]; lzw->lzwbits += lzw->lzwcs; return (raw&lzw->lzwmask);

  25. Komprimieren JPEG Sechs Schritte zum s/w JPEG Image In Blöcke gruppieren; Zentrieren um Null. DCT jedes Blocks. Elimieren einiger Werte durch "quantization". 8 x 8 Blöcke  lineare Sequenz, per EntropyEncoding. Run lengthencoding. Huffmanencoding. Vor diesen Schritten im 24 Bit Fall: Transformation RGB  YCbCr.

  26. Danke für heute!

More Related