473,473 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

While the reading of image for RGB pixel values there is different value of green in

1 New Member
I want to obtain the pixel values for RGB from image.I did it in Matlab and Python but i obtained different values especially at the green value. I'll appreciate if you have an advice about this matter. Thanks Here is my code in python
Expand|Select|Wrap|Line Numbers
  1. from PIL import Image
  2. import numpy as np
  3.  
  4. im = Image.open("lena.jpg")
  5. imPixelVal = np.ones(np.size(im))
  6. imSize = np.size(im)
  7.  
  8. for i in range (0,imSize[0]):
  9.             for j in range (0,imSize[1]):         
  10.                 ij = i , j
  11.                 p = im.getpixel(ij)
  12.                 imPixelVal[i,j] = (0.2989 * p[0]) + (0.5870 * p[1]) + (0.1140 * p[2])
  13.                 print p[0]
  14.                 print p[1] 
  15.                 print p[2]
  16.  
Also this is the code in Matlab:

Expand|Select|Wrap|Line Numbers
  1. Im=imread('lena.jpg');
  2. Img = (ones(size(Im,1),size(Im,2))); 
  3.  
  4. for i=1:size(Im,1)
  5.       for j=1:size(Im,2)
  6.                 Img(i,j)=0.2989*Im(i,j,1)+0.5870*Im(i,j,2)+0.1140*Im(i,j,3);
  7.       end
  8. end
  9. Im(1,1,1)
  10. Im(1,1,2)
  11. Im(1,1,3)
Aug 22 '14 #1
0 1026

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image....
3
by: khaleel.alyasini | last post by:
Hi, currently I'm working on DCT algorithm on C++. I was wondering if anyone out there could point me out how to seperate the pixel values into DCT blocks. Here, i have enclosed my source...
2
by: ajay_itbhu | last post by:
Hi everyone, I want to read the pixel values of 2 similar images in bitmap format like 2 continuous frame of a video for calculating the median. But i dont know how to read the pixel values of...
1
by: doubts | last post by:
Hi, I have a query regarding reading Image Property for button from a XML file . I read XML files to Generate Screens using System.Windows.Forms.Controls .The XML file is read and properties...
5
by: sascha.folville | last post by:
Hi, I've some trouble reading the containing frames of a multiframe tiff. First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is a CCITT again ... and so on. My function...
1
by: paulnamroud | last post by:
Hi Guys, I have a weird problem. While reading my csv file some data a returned as null. When the routine reads values in the column "Size_Code" (like "S",, "M"...) it returns "NULL". When...
2
by: shg | last post by:
Hi, Can anyone guide me on How can I make/create a jpg file if I have image pixel values?
1
by: ShafeeqRahman | last post by:
I am not getting the value of some excel cells while reading it from vb6. The code is as follows. The cells has some numeric values. Is it the problem of the format of the cells in excel. When I...
0
by: sunnycs121 | last post by:
I am simply taking the pixels values from jpeg image using the function imagecolorat() and then creating a jpg image back again by giving those pixel values to imagesetpixel(). the name of new image...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.