flat assembler
Message board for the users of flat assembler.

Index > Main > Scaling a image

Author
Thread Post new topic Reply to topic
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
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.
Post 25 Aug 2008, 15:53
View user's profile Send private message Reply with quote
avi



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

Smile
Post 25 Aug 2008, 17:17
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
you can try with raytracing approach.
i'll try it one day.
Post 25 Aug 2008, 17:46
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



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

PS: And how does the raytracing approach go edfed ?.
Post 25 Aug 2008, 18:14
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
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.
Post 25 Aug 2008, 20:05
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
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.
Post 25 Aug 2008, 21:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Madis731



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

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

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

One more link that you probably found yourself already:
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!
Post 26 Aug 2008, 07:09
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17661
Location: In your JS exploiting you and your system
revolution
Madis731 wrote:
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?
note: The linked documents can not be downloaded from the public version of this site.
Post 26 Aug 2008, 07:18
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
Madis731: Is this something like what your looking for IIR , Lanczos ?
Post 26 Aug 2008, 09:43
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
revolution wrote:
So did you read the note at the top of the page?
note: The linked documents can not be downloaded from the public version of this site.

Oops, nope, it was too small Smile
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 Smile

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 26 Aug 2008, 10:36
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Thanks all for the links and perdo, i have got enough info, so now i can start coding and than optimizing.
Thanks again.
Post 26 Aug 2008, 14:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.