GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 22, 2014 6:13 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Grayscale image and OS version issue
PostPosted: Tue May 07, 2013 7:46 am 
Offline
Familiar Face

Joined: Wed Sep 19, 2012 9:08 am
Posts: 10
Hi all,

I write a program to count the intensity value of each gray level(0~255) in grayscale image.
The strange thing is I got the different result when I ran it in different OS version(Win7 32bit pro and Win XP 32 bit pro),
the GTK version(2.24),program and grayscale image are the same besides OS version.

Could anyone give me a favor.

please find enclosed.
(grayscale image,count table)

thank you.
Jay.


Attachments:
File comment: grayscale image
tp1.JPG
tp1.JPG [ 1.41 KiB | Viewed 666 times ]
File comment: as title
count2.jpg
count2.jpg [ 226.15 KiB | Viewed 666 times ]
File comment: as title
count1.jpg
count1.jpg [ 209.25 KiB | Viewed 666 times ]
Top
 Profile  
 
 Post subject: Re: Grayscale image and OS version issue
PostPosted: Fri May 10, 2013 3:07 pm 
Offline
GTK+ Geek

Joined: Fri Sep 04, 2009 6:53 am
Posts: 68
I suspect gtk uses for decoding of jpeg images the functions of the os, which might have changed between the two version. Encoding of images in jpeg is lossy. And so might the decoding not be exact. http://en.wikipedia.org/wiki/Jpeg#Required_precision.

Have you tried an bmp file wich is lossless?

By the way using python2 and python-imaging with:

Code:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import Image

histo=Image.open("tp1.JPG").convert("L").histogram()
for i in range(222,256):
    print i, histo[i]

# How long is your program?


I'll get:

Code:

222 14
223 8
224 8
225 10
226 15
227 10
228 9
229 12
230 12
231 12
232 14
233 7
234 22
235 12
236 14
237 14
238 17
239 19
240 23
241 25
242 34
243 35
244 20
245 32
246 40
247 30
248 35
249 54
250 73
251 78
252 177
253 292
254 536
255 12375



Top
 Profile  
 
 Post subject: Re: Grayscale image and OS version issue
PostPosted: Wed May 15, 2013 8:44 am 
Offline
Familiar Face

Joined: Wed Sep 19, 2012 9:08 am
Posts: 10
Hi sir,

I had tried to load image in two kinds of OS and it looked like you are right.
When I turn it into bmp format,I get the identical grayscale intensity.

my program is as follows:

Code:
#define MAX_VAL 256
int itst[MAX_VAL];
//===statistics===//
for(j=0;j<height;j++){
for(i=0;i<width;i++){
p=pixels+j*rowstride + i*n_channels;                  
itst[p[0]]++;                   
}
}

//===out put===//
for(i=0;i<MAX_VAL;i++){
if(itst[i]!=0){
g_print("The count of gray level %d intensity is %d\n",i,itst[i]);
}
}


thanks for your help :P

Jay.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 4 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group