Programming for Electrical Engineering
Blob Detection – Part 1
Background
Transfer the files to your repl.it account to get started.
The code is designed to be run on input files at the command like.
Compile the code using the command window:
g++ DetectBlob.cpp
this will create the executable: a.out
which you will run using the command window:
./a.out test.txt
./a.out image_license_plate.txt
Inside the code file, there are two C++ classes:
class Blob
class BlobSystem
You will use the member functions of the class Blob to complete the coding of the member functions of BlobSystem
The pipeline of the BlobSystem looks like this:
[Programming Task 1]
BlobSystem::Phase1_DetectBlobs()
This code generates the LabelBuffer array correctly from the PixelBuffer
For example, the result of the PixelBuffer array:
Row/Col 0 1 2 3 4
0 0 1 0 1 1
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 1 1
4 1 0 0 1 1
For example, the result of the LabelBuffer array:
Row/Col 0 1 2 3 4
0 0 1 0 2 2
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 3 3
4 4 0 0 3 3
[
Programming Task 2]
void BlobSystem::Phase2_IterativeLabeling()
The code of this task is to iteratively solve the label connections:
LabelBuffer Before:
Row/Col 0 1 2 3 4
0 0 1 0 2 2
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 3 3
4 4 0 0 3 3
LabelBuffer After:
Row/Col 0 1 2 3 4
0 0 1 0 1 1
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 3 3
4 4 0 0 3 3
[Programming Task 3]
void BlobSystem::Phase3_AssignBlobIDs()
The code of this task is to re-number the labels in the LabelBuffer and assign the new numbers to the BlobBuffer. At the same time, the phase code must create a Blob instance and add it to the vector of Blob objects. The vector class is reviewed during lecture to help students.
LabelBuffer Before:
Row/Col 0 1 2 3 4
0 0 1 0 1 1
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 3 3
4 4 0 0 3 3
BlobBuffer After:
Row/Col 0 1 2 3 4
0 0 1 0 1 1
1 0 1 1 1 0
2 0 0 0 0 0
3 0 0 0 2 2
4 3 0 0 2 2
For the above example, 3 blob instances should be created in the BlobVector fo the BlobSystem.
Blob New_Blob(Label_Number);
this->BlobVector.push_back(New_Blob);
void BlobSystem::Phase3_AssignBlobIDs()
{
// Change the Label Buffer to be updated from the label table
// Scan the entire LabelBuffer array and change any value of array
// Two parts:
// 1-Assign Label Number to the spots of the BlobBuffer array, this
// is done by scanning the LabelBuffer and finding the number of
// unique labels
// 2-For each new label, add to this->BlobVector Create new instances of
// the Blob class and add to the
for (int row=0; row < this->NumRows; row++) {
for (int col=0; col < this->NumCols; col++) {
// Student fill in code
}
}
}
[Programming Task 4]
void BlobSystem::CalculateBlobInformation()
Calculate the mass/boundary information from BlobBuffer.
Mass Min Row Min Col Max Row Max Col
Finish the coding of the following routine, by scanning the BlobBuffer array for each blob assigned to the BlobVector. Use the member functions SetMaxRow, SetMinRow, SetMaxCol, SetMinCol, and SetMass for the blob.
void BlobSystem::CalculateBlobInformation()
{
for (int index = 0; index < this->BlobVector.size(); index++) {
int blob_id = this->BlobVector[index].ID;
// For each blob ID, scan over the BlobBuffer
// Start with these initial condition
int Mass = 0;
int MinRow = this->NumRows;
int MaxRow = 0;
int MinCol = this->NumCols;
int MaxCol = 0;
// For each Blob ID, scan the LabelBuffer
// Student fill in information.
for (int row = 0; row < this->NumRows; row++)
{
for (int col = 0; col < this->NumCols; col++)
{
}
}
// Set the values
this->BlobVector[index].SetMaxRow(MaxRow);
this->BlobVector[index].SetMinRow(MinRow);
this->BlobVector[index].SetMaxCol(MaxCol);
this->BlobVector[index].SetMinCol(MinCol);
this->BlobVector[index].SetMass(Mass);
}
}
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.