473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I need help guys in its urgent..............

You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity.

Here is a sample PGM image with 10 columns and 4 rows:

P2
# Comment lines
# They follow the P2 line.
# There could be 0, 1 or more
10 4
255
10 10 15 17 10 0 10 4 5 8
10 3 10 10 12 10 255 32 12 12
12 3 10 7 10 6 10 10 5 6
10 10 7 8 1 2 3 4 10 10

You can see the image data is all text, so it should be possible to read it with fscanf.
Hii help me in solving the below program in c++ which i need to submit on 27th, an assignment given to me in advance algorith course.

I am also sending the explantion of the things to be done in the program if some one gets any doubt.......................

-----------------------------------------------------------------------------------------------------------------------
Explanation:

In the question he gave us the below given image as an example,
10 4
255
10 10 15 17 10 0 10 4 5 8
10 3 10 10 12 10 255 32 12 12
12 3 10 7 10 6 10 10 5 6
10 10 7 8 1 2 3 4 10 10

The starting 10 & 4 are number of columns & no of rows and 255 is the max no present in thearray of no's.

So our job will be to read tha above image according to rows and columns using the function fscanf or we can use fgets funtion also. Next the numbers with same value are considered to be in same set or blob. so when we read a number we will check in all 8directions of that number to find the number beside that is in the same blob or not. Even a single number without any matching neighbours is considered a blob like 15, 17,.....and where as all 10's make a blob.Thus the blobs with same value will be joined (union) like 1st two 10's. So the disjoint set algorithm can be used to solve the program.

Finally we need to print the grayscale value which is nothing but the number itself, no of blobs which is nothing but the blobs of the same no's like 12 has three blobs, no of pixels is nothing but the total no of numbers present in smallest blob, biggest blob and all the blobs of the same number and average no of pixels is nothing but average of the sets or blobs of same value like avg for 12 is 4/3 = 1.33 and for 7 is 2.........
------------------------------------------------------------------------------------------------------------------------------------------
Given below is the question for the program.
----------------------------------------------------------------------------------------------------------------------------------------
Your program should be executed as

blobalyzer image_file_name

The file name will be available as argv[1] provided argc is greater than 1. Your program should print out a usage message if argc is 1.

Your program should read the file and place pixels into the proper blob. Initially each pixel will be in a blob identified as its row number times the number of columns plus the column number. Assuming you number rows and columns from 0, the example would have blobs numbered 0 through 39.

Your should go through the very first row of the file and join together the blobs for adjacent pixels with the same grayscale value. In the example this would mean that blobs 0 and 1 would be joined since the values are both 10.

After the first row you should compare each pixel with the pixels to the left, above, above-left and above-right. Clearly pixels in column 0 would be compared only with pixels above. By the time you finish row 1 in the example all the 10's would be in the same blob. Eventually all the 10's will be merged into a single blob.

After processing the image your program needs to print out a nice tabular report detailing for each grayscale value in the image:

the grayscale value
the number of blobs of that value
the number of pixels in the smallest blob of that value
the number of pixels in the largest blob of that value
the number of pixels in all the blobs of that value
the average number of pixels in the blobs of that value
If you use multiple files submit an archive of all the files in tar, tgz or zip format. Please do not use rar.
Mar 25 '07 #1
1 1940
sicarie
4,677 Expert Mod 4TB
Welcome to theScripts.

Here are our Posting Guidelines, and specifically:

Posting Homework or Coursework Questions and Answers
This site is not a place where you can get your homework and course work done for you. Ignoring the questionable morals of getting someone else to do your work towards a formal qualification you will learn a lot more by attempting the problem yourself, then asking for help with the bits that are not working. You will be more likely to get help if you appear to have made an attempt at the problem yourself.

* If it appears that the question has just been pasted directly from a text book or coursework assignment our moderators have been instructed to meet this with a set response. This is a pre-written message asking you to make some attempt at the assignment yourself before asking questions about specific problems and referring you to this FAQ.
* Do NOT post your complete source code. Remember, you found this site, so can your professors and tutors and they are likely to take a dim view if you hand in something that appears to be copied from this site. In most academic institutes the minimum response to copying of assignments is a 0 mark for the assignment in question. If you post your entire code your professor will not know it was your work, you may be penalised for copying from yourself.
* If an expert requests that you provide more of your code then you can PM it to them, however please do not PM them your code unless requested.
* Acceptable questions that students can ask are on functionality and theory or syntax corrections in small posted code snippets.
* Please make sure you have asked an actual question worded in English outside of the text of your assignment that you have posted.
With those in mind, what is your specific question about the program?
Mar 26 '07 #2

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

Similar topics

2
by: WantedToBeDBA | last post by:
Hi all, We have db2 installed on AIX box (db2 version - 8.1). Its started and i am able to view 50000(default port) in netstat(netstat -a -n). But when i try to connect using telnet, i am getting...
0
by: Max | last post by:
Hey guys, I'm in urgent need of a full featured shopping cart. Something 100 times better than Miva or VP-ASP. They are very buggy! One that runs in ASP.NET and SQL Server would be great, but not...
6
by: Mike L. | last post by:
Hi, Pls, beware that I'm new to this :) I've developed several web appl, either with ASP or ASP.NET. All using SQL server as the back end. In my development environment, I have a single...
6
by: Lucky | last post by:
hi guys, i'm looking for one RegEx which can find matches from the bunch of lines. i want to find all the matches of "<a * href=*>*</a>". if any one can help me out here, please do come forward. ...
1
by: Sanjiv | last post by:
Hi guys i need to deserialize the xml file in C#. and that file has about 300 nodes? how can i do that. plz help me. its urgent thanks in advance Sanjiv
4
by: csharpguy | last post by:
Guys, I am using c# to call some DLL. Here is my situation, I tried to create reference to this dll in my project and I am able to call this dll successfully, but when actual dll is upgraded to...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
7
by: ne0 | last post by:
Hey guys, hope you could help me, i am writing a program in which it reads a file text and than generates a report containing a list of words of 1letter, 2letters.. every list should be made in...
1
by: shafaeat | last post by:
hi guys, can anybody help me with a c code to convert an 90*90 binary image to 100*100 binary image? its very urgent.
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.