flat assembler
Message board for the users of flat assembler.

 Index > Main > Scaling a image
Author
Dex4u

Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 25 Aug 2008, 15:53
Does anyone have any good links to image scaling info or perdo code etc.
As i need to scale a bmp image up or down in size.
Thanks.
25 Aug 2008, 15:53
avi

Joined: 24 Jun 2008
Posts: 23
Location: usa
avi 25 Aug 2008, 17:17
Dex wrote:
...need to scale a bmp image up or down in size...
here's one and here's another.

25 Aug 2008, 17:17
edfed

Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 25 Aug 2008, 17:46
you can try with raytracing approach.
i'll try it one day.
25 Aug 2008, 17:46
Dex4u

Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 25 Aug 2008, 18:14
Thanks, but it was more the maths part.

PS: And how does the raytracing approach go edfed ?.
25 Aug 2008, 18:14
Borsuc

Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 25 Aug 2008, 20:05
edfed wrote:
you can try with raytracing approach.
i'll try it one day.
That's awfully slow and you can't use "edge-detection" algorithms easy either.
25 Aug 2008, 20:05
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 25 Aug 2008, 21:13
If want just simple algorithm, it is very similar thing as line drawing (?bresenham?) algorithm. Scaling one line would be:

simplest with real numbers:
Code:
for (x=0; x<dest_xsz; x++) {
destbmp[x] = srcbmp[(x/dest_xsz)*src_xsz]
}

constant stuff removed from loop: (x/dest_xsz)*src_xsz = x*(src_xsz/dest_xsz), second parenthesis is constant
Code:
step = src_xsz / dest_xsz;
for (x=0; x<dest_xsz; x++) {
destbmp[x] = srcbmp[step*x]
}

real numbers removed: we multiply all "stepping" constants with dest_xsz to remove real numbers
Code:
step = src_xsz;
d = 0;
srcindex = 0;
for (x=0; x<dest_xsz; x++) {
d += step;
if (d > dest_xsz) {
srcindex++;
d-=dest_xsz;
}
destbmp[x] = srcbmp[srcindex]
}

To support also shrinking, simply change last "if" to "while".

Of course, you need to find good initializer for "d" and fix boundaries, to make sure pixels are evenly selected. That is the harder part.
25 Aug 2008, 21:13

Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
I believe vid's scaling is called ...heh I can't even remember it... without any kind of resampling I mean

Some hardcore for increasing image: link
but of course its the best.

For lowering image dimensions there's vids representation with SSE help that might do the trick.

http://www.compuphase.com/graphic/scale2.htm

Btw, does anyone know how to get to the C-drive of http://www.sandpile.org/docs/intel/isa-ext.htm ? I would love to see those PDF-s. Especially scoll down to AVX!
26 Aug 2008, 07:09
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20210
revolution 26 Aug 2008, 07:18
Btw, does anyone know how to get to the C-drive of http://www.sandpile.org/docs/intel/isa-ext.htm ? I would love to see those PDF-s. Especially scoll down to AVX!
So did you read the note at the top of the page?
26 Aug 2008, 07:18
Alphonso

Joined: 16 Jan 2007
Posts: 295
Alphonso 26 Aug 2008, 09:43
Madis731: Is this something like what your looking for IIR , Lanczos ?
26 Aug 2008, 09:43

Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
revolution wrote:
So did you read the note at the top of the page?

Oops, nope, it was too small
Its a rather tempting linking they got there: file:///c:/home/manuals/intel/isa/avx/lanczos.pdf

Alphonso wrote:
Madis731: Is this something like what your looking for IIR , Lanczos ?

Hmm, that was my half-goal. Actually seems that they've gathered interesting documents in one place, but when the Intel PDFs are public, how can or WHY? would sandpile hide them from the masses?

...
I hope the Alphonso's posted links help Dex4u develop image scaling

_________________
My updated idol http://www.agner.org/optimize/
26 Aug 2008, 10:36
Dex4u

Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 26 Aug 2008, 14:38
Thanks all for the links and perdo, i have got enough info, so now i can start coding and than optimizing.
Thanks again.
26 Aug 2008, 14:38
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum