If you are developing an image processing application using OpenCV and you want to display pixel values of images, it might not be possible to display all pixels on console due to large size of images. Following code snippet dumps the pixel values of OpenCV image to a text file in readable format. You can then open the created file in any text editor and analyze the pixel values of image.
Recently i was developing an image processing application and my output file was DLL rather than executable. One of the functions in code was returning black image, to debug my code i wrote this function and dumped intermediate images to files and eventually i was able to fix the bug.
#include<stdio.h>
/*
Function takes OpenCV image as input and dumps its pixels to a file specified by filename in function arguments.
*/
int WritePixelsToFile(IplImage *img,const char *filename)
{
/*open a file in text mode with write permissions.*/
FILE *file = fopen(filename, "wt");
if(file==NULL)
{
/*If unable to open the specified file display error and return.*/
perror("Unable to open specified file");
return -1;
}
int i,j;
CvScalar s;
CvSize size=cvGetSize(img);
for(i=0;i< size.height;i++)
{
for(j=0;j< size.width;j++)
{
s=cvGet2D(img,i,j); // get the (i,j) pixel value
fprintf (file,"%f\t",s.val[0]); // dump the (i,j) pixel value in file
}
fprintf(file,"\n");//write new line in file to seperate rows.
}
/*release the file pointer.*/
fclose(file);
return 1;
}
Posted: 7th October 2010 by Adnan Noon in Pakistan Affairs
General Musharraf conducted a coup on 12th Oct 1999 and dismissed then elected government of Nawaz Sharif by abrogating the constitution. Following is the long list of his crimes.
- Abrogation of constitution and dismissal of elected government.
- Imposition of dictatorial rule in the country.
- The Lal Masjid Operation.
- Murder of Nawab Akber Bugti.
- Promulgation of the defunct National Reconciliation Ordinance (NRO).
- Removal of Justice Iftikhar Chaudhry as the chief justice of Pakistan.
- Incident of 12th May 2007.
- Starting war against its own people in interest of United States.
- Illegal transfer of Pakistani citizens including Dr. Afia Siddiqui to United States for dollars.
- Allowing drone attacks in territory of Pakistan by United States.
- Abduction of innocent Pakistanis.
- Pakistan Steel Mills privatization case.
- Punjab Bank Fraud case.
- Putting seeds of suicide bombings in country.
- Destruction of the moral and Islamic values of nation in the name of enlighten moderation.
- Making the “Beard” and “Burqa/Hijaab” as symbol of terrorism.
- Eliminating Kashmir freedom movement.
Posted: 7th October 2010 by Adnan Noon in Pakistan Affairs
Economic Comparison 1999-2007.
| Category |
1999 |
2007 |
| Economy |
$ 75 billion |
$ 160 billion |
| GDP Purchasing Power Parity (PPP) |
$ 270 billion |
$ 475.5 billion |
| GDP per Capita |
$ 2,000 |
$ 3,004 |
| Pak revenue collection |
Rs. 305 billion |
Rs. 708 billion |
| Pak Foreign reserves |
$ 700 million |
$ 17 billion |
| Pak Exports |
$ 7.5 billion |
$ 18.5 billion |
| Textile Exports |
$ 5.5 billion |
$ 11.2 billion |
| KHI stock exchange |
$ 5 billion at 700 points |
$ 70 billion at 14,000 points |
| Foreign Direct Investment |
$ 1 billion |
$ 8 billion |
| Debt servicing |
65% of GDP |
26% of GDP |
| Poverty level |
34% |
24% |
| Literacy rate |
45% |
53% |
| Pak Development programs |
Rs. 80 billion |
Rs. 520 billion |
- Public sector institutions numbers increased from 110,267 (in 1999) to become 164,579 (2006)
- Private sector institutions numbers increased from 36,096 (in 1999) to become 81,103 (in 2006).
- There were 2652 PhDs in Pakistan in 1999 which increased to 6405 by 2009. 3753 PhDs were produced in 10 years.
- IT industry value increased to around $2 billion, including $1 billion exports and employed around 90,000 professionals.
- CNG sector attracted over $70 billion investment; and created 45,000 jobs.
- Telecom sector attracted around $10 billion in investment and created above 1.3 million jobs.
- Industrial Parks were being setup throughout the country for the first time in Pakistani history! M3 estate, Sunder industrial estate, Chakri, etc.
- Major Mega projects like the Saindak, Rekodiq, Marble production, Coal production and Mining & Quarrying were being pursued.
- 4 dams: Mirani, Subakzai, Gomalzam, Khurram Tangi dams.
- Motorways completed or under construction: M1, M3, M8, M9, M10, M11.
- Six major highways under construction.
- GWADAR advance mega Sea port developed under his vision!
- Historic 100% increase in Tax collection of $11 billion.
- Large scale manufacturing is at 30 years high, and Construction activity is at 7 years high.
- Newly found World class copper- gold deposits in Chagai will fetch $600 million per year.
- A new Oil refinery with UAE will fetch $5 billion & will process 300,000 oil barrels a day.
- Industrial sector registered 26% growth.
- GDP growth was 3.1% in 1999 which was recorded 8.4% in 2005 and 7% in 2007.
source