Обсуждение: medical image on postgreSQL?

Поиск
Список
Период
Сортировка

medical image on postgreSQL?

От
jp_santosa@yahoo.com (Santosa Budi)
Дата:
Dear Friends,

Apologize.. this posting may not relevance enough to this group.
I am very much a newbie to posgreSQL database programming and would like
assistance. I am finding an example how to use the database (postgreSQL)
to store MRI/CT image data using C language interface. I heard something
pronounced like: Content-Based Image Retrieval.. but I still do not have
any idea for a HowTo do on postgreSQL database.

If possible, could someone describe the skeleton for such database pro-
gramming.. nor if there are examples or some references/tutorial/books
concering this kind database programming, could someone give me pointers
to both the site online or book store.

Sorry if this is the incorrect place for this post, but I do need helps
and figured to start with. Thank you for your helps.

santosa budi.-

Re: medical image on postgreSQL?

От
"scott.marlowe"
Дата:
On 9 Apr 2003, Santosa Budi wrote:

> Dear Friends,
>
> Apologize.. this posting may not relevance enough to this group.
> I am very much a newbie to posgreSQL database programming and would like
> assistance. I am finding an example how to use the database (postgreSQL)
> to store MRI/CT image data using C language interface. I heard something
> pronounced like: Content-Based Image Retrieval.. but I still do not have
> any idea for a HowTo do on postgreSQL database.
>
> If possible, could someone describe the skeleton for such database pro-
> gramming.. nor if there are examples or some references/tutorial/books
> concering this kind database programming, could someone give me pointers
> to both the site online or book store.
>
> Sorry if this is the incorrect place for this post, but I do need helps
> and figured to start with. Thank you for your helps.

Good of a place as any :-)

If you want to store a binary file in postgresql, you can either use the
semi-non-standard large object interface (I'd recommend against it
personally) or you can encode your data and store it in the database.
while there is a bytea type that works ok, but my preferred method is more
transportable:  base-64 encode the data, then store that in a text field.
Since postgresql compresses text fields automagically, you don't have to
worry about base-64 being too bloaty, since the only bloat will be when
you're actually moving the file into / out of the database.

pseudo code:

$file = "/somedir/somefile.gif";
$fp = fopen($file,"r");
$img=fread($fp,filesize($file));
$b64 = base64encode($img);
$b64=pg_escape($b64);
$query = "insert into table (bigfield) values ('$b64');


Just reverse the process to get it back.