WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

Antwort
 
Themen-Optionen Ansicht
Alt 23.02.2001, 22:31   #1
LDIR
Retro Computing Fan
 
Benutzerbild von LDIR
 
Registriert seit: 30.01.2001
Ort: Wien 21
Alter: 53
Beiträge: 1.723

Mein Computer

Frage

Hat Jemand einen Link oder nähere Informationen über Floyd- Steinberg Algorythmus. Ordered Dithering ist mir inzwischen bekannt und ich kann es anwenden (außer wenn ich Farbbilder als Ergebnis haben will), aber mit FS bekommt man bessere Ergebnise, meine Versuche endeten aber bisher mit verrauschten Bildern.
____________________________________
Meine guten PCs:
ZX Spectrum: 48+,128+,+2,+2a,+3,SAM Coupé. Commodore: C64 I/II, VC20, A500 mit GVP A530 40Mhz,A2000 GVP 030/33 18MB RAM, A600HD,A1200. Atari: 130XE, 800XL, Mega STE 4MB, Mega ST4. MSX: Philips, Sony.
LDIR ist offline   Mit Zitat antworten
Alt 23.02.2001, 23:12   #2
MasterX
Master
 
Registriert seit: 18.05.2000
Beiträge: 556


Pfeil bitteschön :o)

Hier der Link zu einer Seite wo du dir den C-Source für Floy/Steinberg-Dithering saugen kannst.
Ist übrigens das FS-Plugin für GIMP; sollte also auch von der Qualität her nicht schlecht sein )

http://www.home.unix-ag.org/simon/gimp/fsdither.html

Grüße, MasterX
MasterX ist offline   Mit Zitat antworten
Alt 23.02.2001, 23:18   #3
MasterX
Master
 
Registriert seit: 18.05.2000
Beiträge: 556


Lächeln noch was ;o)

Hab hier noch was für dich .... ist wahrscheinlich sogar besser - weil verständlicher, da es nicht plugin konzipiert ist.

/*
* dither -- use a reduced set of grey values to represent an image
*
* Copyright (C) 1988 by Dale Schumacher.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "as is" without express or
* implied warranty.
*
*
* Notes:
*
* [1] Floyd-Steinberg dither:
* I should point out that the actual fractions we used were, assuming
* you are at X, moving left to right:
*
* X 7/16
* 3/16 5/16 1/16
*
* Note that the error goes to four neighbors, not three. I think this
* will probably do better (at least for black and white) than the
* 3/8-3/8-1/4 distribution, at the cost of greater processing. I have
* seen the 3/8-3/8-1/4 distribution described as "our" algorithm before,
* but I have no idea who the credit really belongs to.

* Also, I should add that if you do zig-zag scanning (see my immediately
* previous message), it is sufficient (but not quite as good) to send
* half the error one pixel ahead (e.g. to the right on lines you scan
* left to right), and half one pixel straight down. Again, this is for
* black and white; I've not tried it with color.
* --
* Lou Steinberg
*/

static char _Program[] = "dither";
static char _Version[] = "1.3";
static char _Copyright[] = "Copyright 1988 by Dale Schumacher";

#include <stdio.h>
#include <ctype.h>
#include "pxm.h"

#define DEBUG(x) if(0)/* x */

#define range 255 /* maximum pixel output value */

int levels = 2; /* number of output levels */

banner()
{
printf("%s v%s -- %s\n", _Program, _Version, _Copyright);
}

usage()
{
fprintf(stderr,
"usage: %s [-n levels] inpxm outpxm\n",
_Program);
exit(1);
}

main(argc, argv)
int argc;
char *argv[];
{
register PX_DEF *ipx, *opx;
FILE *f;
register int c;
register char *p;
extern int optind;
extern char *optarg;

while((c = getopt(argc, argv, "n:V")) != EOF)
{
switch(c)
{
case 'n':
levels = atoi(optarg);
break;
case 'V':
banner();
exit(0);
case '?':
default:
usage();
}
}
if((argc - optind) < 2)
usage();
else
{
ipx = px_ropen(argv[optind++]);
opx = px_wopen(argv[optind++],
(PXT_PIX | PXT_BIN),
ipx->px_width, ipx->px_height, 8, NULL);
dither(ipx, opx);
px_close(ipx);
px_close(opx);
}
exit(0);
}

dither(ipx, opx)
PX_DEF *ipx, *opx;
{
unsigned int xsize, ysize;
unsigned int y, x;
register int xslop, *yslop, dslop;
register int i, j, k, t, q;
register PX_BYTE *ibuf, *obuf;

xsize = ipx->px_width;
ysize = ipx->px_height;
ibuf = px_rowalloc(xsize, ipx->px_psize);
obuf = px_rowalloc(xsize, opx->px_psize);
yslop = (int *) px_alloc(xsize * sizeof(int));

t = ((range + 1) * 2) / levels; /* threshold factor */
q = range / (levels - 1); /* quantization factor */
j = (9 * range) / 32;
for(x=0; x<xsize; ++x)
yslop[x] = j;

for(y=0; y<ysize; ++y)
{
xslop = (7 * range) / 32;
dslop = range / 32;
px_rrow(ipx, ibuf);
for(x=0; x<xsize; ++x)
{
i = px_rgrey(ipx, ibuf, x);
i += xslop + yslop[x];
j = (i / t) * q;
if(j > range) /* quick hack to fix overflow */
j = range; /* which shouldn't happen */
px_wgrey(opx, obuf, x, j);
i = i - j;
k = (i >> 4); /* (i / 16) */
xslop = 7 * k;
yslop[x] = (5 * k) + dslop;
if(x > 0)
yslop[x-1] += 3 * k;
dslop = i - (15 * k);
}
px_wrow(opx, obuf);
}
}




P.S. nicht von mir !!!!!!!! ;o)
MasterX ist offline   Mit Zitat antworten
Alt 23.02.2001, 23:59   #4
LDIR
Retro Computing Fan
 
Benutzerbild von LDIR
 
Registriert seit: 30.01.2001
Ort: Wien 21
Alter: 53
Beiträge: 1.723

Mein Computer

Idee Danke

Danke an Euch, ich muß es jetzt nur noch für Basic umschreiben und versuchen es in mein Programm einzubauen. mal sehen, hoffentlich klappt es... Etwas kompliziert das ganze!
____________________________________
Meine guten PCs:
ZX Spectrum: 48+,128+,+2,+2a,+3,SAM Coupé. Commodore: C64 I/II, VC20, A500 mit GVP A530 40Mhz,A2000 GVP 030/33 18MB RAM, A600HD,A1200. Atari: 130XE, 800XL, Mega STE 4MB, Mega ST4. MSX: Philips, Sony.
LDIR ist offline   Mit Zitat antworten
Alt 04.03.2001, 20:44   #5
LDIR
Retro Computing Fan
 
Benutzerbild von LDIR
 
Registriert seit: 30.01.2001
Ort: Wien 21
Alter: 53
Beiträge: 1.723

Mein Computer

Böse Bin zu doof für C!

Da ich noch nie was mit C zu tun hatte, habe ich schwierigkeiten diese Routine zu Basic umzusetzen, kann mir bitte Jemand helfen?
____________________________________
Meine guten PCs:
ZX Spectrum: 48+,128+,+2,+2a,+3,SAM Coupé. Commodore: C64 I/II, VC20, A500 mit GVP A530 40Mhz,A2000 GVP 030/33 18MB RAM, A600HD,A1200. Atari: 130XE, 800XL, Mega STE 4MB, Mega ST4. MSX: Philips, Sony.
LDIR ist offline   Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 04:56 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag