Question: Quadtrees Description A quadtree is a representation format used to encode images. The fundamental i dea behind the quadtree is that any image can be
Quadtrees
Description
A quadtree is a representation format used to encode images. The fundamental i dea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again be split in four sub quadrants, etc. In the quadtree, the imag e is represented by a parent node, while the four quadrants are represented by our child nodes, in a predetermined order.
Of course, if the whole image is a single color, it can be represented by a quadtr ee consisting of a single node. In general, a quadrant needs only to be subdivide if it consists of pixels of different color. As a result, the quadtree need not be of uniform depth.
A modern computer artist works with black and white images of unit for a total of pixels per image. One of the operations be perform is addin two images together, to form a new image. In the resulting image a pixel is bla if it was black in at least one of component images, otherwise it is white.
This particular artist believes in what be calls the preferred fullness: for an image to be interesting ie to sell for big bucks the most important property is the nu mber of filled black pixels in the image. So before adding two images together, he would like to know how many pixels will be black in the resulting image. your job is to write a program that, given the quadtree representation of two images, calculates the number of pixels that are black in the image, which is the result of adding the two images together.
In the figure, the first example is shown from top to bottom as image, quadtree, preorder string defined below and number of pixels. The quadrant numbering shown at the top of the figure.
peipieeie
peivperie
ppeevirperie
Input
The first line of input specifies the number of test cases your program has to process.
The input for each test case is two strings, each string on its own line. The string is the preorder representation of a quadtree, in which the letter indicates a par ent node, the letter full a black quadrant and the letter e empty a white quad rant. It is quaranteed that each string represents a valid quadtree which contains at most characters.
Output
For each test case, print on one line the text There are black pixels. wh ere is the number of black pixels in the resulting image.
Sample Input
ppeeefpffeefe
pefepeefe
peeef
peefe
peeef
peepefefe
Sample Output
There are black pixe is
There are black pixe is There are black pixe is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
