Skip to main content
gamedev.net
🔒 Locked

Circular image format?

Started by gavco98 Sep 19, 2005 at 5:07 AM 14 replies 2.1k views
Original Post
gavco98
gavco98
Just having a little discussion with a colleague, and the question came up of why all images are rectangular, and rely on a grid based system to store pixel colours etc. Would it be possible to instead a non-rectangular image format...ie circular instead. By that I dont mean like a GIF with transparancy, but instead an image that is circular rather than rectangular. Is it possible, and how would u store the pixel properties (assuming a bmp style system rather than vector graphics...?)
Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]
Shadowdancer
Shadowdancer
What would you need something like that for anyway?

Of course, it wouldn't be too much of a problem to just have a pixmap storage format that doesn't have its pixels in a regular, rectangular grid but instead in the shape of a (sampled) circle. To get optimal coverage at a given resolution, you'd have to offset the rows with subpixel precision, which would result in a floating point value per row. (That covers one axis, the other axis would still be regular!) That's not too hard, at least in theory.

Another way I just thought of would be to not use rectangular pixels, but partition your disc in rather fine sectors, kind of like a magnetic disc. That would give you optimal coverage of the overall shape, but you'd have to fiddle with the resolution of each "cylinder".

The real fun begins when you try to display that monster. You have to transform from your irregular, roughly disc-shaped grid to the probably regular grid of the display. To do that, you have to re-sample the stored image, which would introduce artifacts. So unless you find yourself a display using the same partitioning as your image file does, you actually wouldn't have a way to do pixel-exact "manual" work on your images, except at high magnification.

Even if you could store and display those images in a feasible way, there'd still be the problem of creating an efficient compression algorithm.

Bonus points for a spherical image.
superpig
superpig
I'm siding with Shadowdancer in that I don't see what this could be used for. To know that would make a world of difference because it would determine the properties required from this 'circular' image.

How important are things like uniform density? How would it be accessed?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
gavco98
gavco98
i now its not exactly very useful.....but its an interesting thought. You gotta push the boundaries to discover just whats possible and whats not.
Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]
superpig
superpig
This isn't pushing any boundaries. We know it's possible to work with a "circular" image - just address your texture using polar coordinates instead of cartesian ones, for example. But what does that help you do?

Sure, you can take a pair of trousers, fill them with chocolate sprinkles and shaving foam, and staple them to a sheep. But why would you want to?

You're not a fan of modern art by any chance are you?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
SiCrane
SiCrane
You can always just switch to a vector image format. Then you can define arbitrary image boundaries. Why stick to just squares or circles when you can make your image bounded with the outline of a cow?
gavco98
gavco98
Quote:
Original post by superpig
Sure, you can take a pair of trousers, fill them with chocolate sprinkles and shaving foam, and staple them to a sheep. But why would you want to?


Because its cool? vector graphics supporting any shape would be ideal, but just for simplicity I thought I would consider just a bmp based circle system.

Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]
DrewGreen
DrewGreen
^ Lol @ superpig

If we're talking about bitmaps here a rectangular grid is the most efficient general case in terms of storage in memory. Trying to store a circle within a rectangle results in less unused space than if you were trying to store a rectangle within a circle. In terms of tradeoffs much more can be done with a rectangular image.
Obviously storing a circle within a circle would result in no unused space but this isn't a common or generic enough case to warrant a circular image format (suitable for general use).
"I must not fear. Fear is the mindkiller. Fear is the little death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past me I will turn to see fear's path. Where the fear has gone there will be nothing. Only I will remain." ~Frank Herbert, DuneMy slice of the web
dimebolt
dimebolt
Quote:
Original post by superpig
This isn't pushing any boundaries. We know it's possible to work with a "circular" image - just address your texture using polar coordinates instead of cartesian ones, for example. But what does that help you do?

Sure, you can take a pair of trousers, fill them with chocolate sprinkles and shaving foam, and staple them to a sheep. But why would you want to?

You're not a fan of modern art by any chance are you?

I think it could be useful to save memory/diskspace for images that happen to be circular.

It would save me quite some video memory if I could send the cylindrical volumes (a set of ct-scan tomographies that I must visualize) to the graphics card in a cylindrical 3D texture.

Tom

EDIT: what DrewGreen said
Daaark
Daaark
dimebolt is the new columbus. People are going to say "500 years ago, people thought images were rectangle!"

dimebolt: ROUND!
superpig: RECTANGLE!
shadowdancer: Why would they be round?
dimebolt: ROUND I TELL YE!
superpig: Bah! Phoohey! Chocolate sprinkles and shaving cream!


superpig
superpig
I always say "Bah! Phoohey! Chocolate sprinkles and shaving cream!" [grin]

OK, I see what you're saying now. We're just looking at ways to lay the texture out in memory such that it's easy to address?

The simplest solution is the one I mentioned - use a rectangular texture addressed with polar coordinates. You don't store any information from 'outside the circle;' however, the benefit comes in the form of increased resolution at the center of the circle, instead of space saving.

If you keep uniform resolution and want to treat it as just a special packing of a rectangular texture which just happens to only contain data in a circular region... hmm. You could probably pack pixels more efficiently by dividing the circle up into slices and laying each slice out in alternating directions, something like:

 ----------(   ----/  )---/-------(   ----/  )---/-------


(please forgive my terrible ASCII art)

This'd give you some wasted pixels at the edges. In theory, if you chop the slices thinner and thinner, you approach the polar coordinate approach [smile]

Beyond that, I'm not sure. You can probably say goodbye to hardware filtering and mipmap support. Maybe you could do something like scanconvert the circle and concatenate each line to produce a 1 by circle_area texture, and then calculate a lookup coordinate in a pixel shader.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
timw
timw
I'd choose an area preserving mapping, such as

s = theta/360
t = sin(phi)/2 + 1/2

I'd think you'd want area preserving property, but
s = " "
t = phi/180 + 1/2

also has advanteges as well, for instiance phi varies uniformly and as such, their is no streaching at the top in the direction of phi.

there is an inharent problem storing things in rectangular form and referencing with (s, t) that is, the pintching at the top of the sphere, this is unavoidable with this scheme. you could probably eliminate it by using 3-d images or something, but that costs a lot in space.

brulle
brulle
Hehe. Nice topic. Keep on smoking crack.
timw
timw
why? there is an inherent complexity in mapping the surface of a sphere to a two dimnsional plane. Mapmakers have dealt with this for hundreds of year at it wasnt trivial, infact there is no really good way to map a plane to a sphere. because of the singularities at the poles, you loose detail or at least it's hard to keep it via modifications of your texture map. surfaces like this are called intrisnically curved, and they pose problems like this. the only perfect solution is to use 3d textures.

Tim
Steadtler
Steadtler

Not a good idea :P

The main reason is that round images would mean round screens to keep any sense, and that round stuff cannot be efficiently packed in boxes.

The other main reason is that cartesian coordinates are orthogonal and circular coordinates are not!

Ok my last main reason is that all image processing algo would be screwed with round images, and that means my job would be a lot more difficult. Please dont tell any of this to my boss.
gavco98
gavco98
Quote:
Original post by Vampyre_Dark
dimebolt is the new columbus. People are going to say "500 years ago, people thought images were rectangle!"

dimebolt: ROUND!
superpig: RECTANGLE!
shadowdancer: Why would they be round?
dimebolt: ROUND I TELL YE!
superpig: Bah! Phoohey! Chocolate sprinkles and shaving cream!


Hey! It was me that proposed the circular image format...Worship me!

They laughed at colombus when he said the world was flat.......
Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.