You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read the image and resize it to appropriate size (here, 600 x 600).
Get the vertices of the object (here, flag) in the original image using the 'vertices' function.
The function converts the image into gray-scale, starts finding the contours and returns the vertices with the largest possible quadrilateral area.
Then we arrange the vertices to the 4 corners of the flag and crop the image accordingly to remove any extra spaces from around it.
We then again get the vertices of the flag in this cropped image.
The top_left, top_right, bottom_left and bottom_right corners are selected based on the linear distance of the four vertices of the quadrilateral found.
Based on these, the correct orientation of the flag is found using the colours of the flag.
We can then generate a flag with the correct orientation based on this information.
Audio Classification
The audio path is given as an input to the function.
The wave_form and samp_rate is found out using the librosa library.
I then used the mel-spectrogram technique to get the power of the audio.
This is then converted to decibles.
The spectrogram image is saved and then read to generate the edges in the image.
Based on a threshold, it is decided if the audio is 'metal' or 'cardboard'.
Text Alignment
The image path is given as an input to the function.
The image is then converted to gray-scale and I applied gaussian blur to it so that only the most intense edges are detected.
The Canny technique is used to detect the edges in the image and then HoughLines algorithm is applied to get straight lines in the image from the detected edges.
Based on these straight lines and the angle they make with the horizontal (0 degrees), the alignment of the text is known and then the text is rotated in the opposite direction by the same angle to straighten it.
If the angle (say, theta) is negative (clockwise), then it is rotated in the opposite direction and by an angle of (360+theta).
Region Detection
The main objective here is to separate the image into two (or more) regions.
With prior information about the image, we can set various threshold ranges based on the colours, contrast, sharpness or other features to extract the required regions.
Here, I've used the colour contrast to separate the lava region from the image.
Based on the lower and upper bound of the colours present in the image, I've created a colour-mask of the image.
This colour mask is then combined with the gray-scale image to create a combined mask of the image.
Then using kernels of size (5, 5), I've created another mask using Morphology, which is then used to detect the contours of the lava region.
Flash No-flash Images
We use flash to light up and area, and capture the surroundings better. But while the flash improves the lighting of the image, it reduces the details because of the reflections.
In this algorithm, I've used the bilateral filter to combine the flash and no-flash formats of the same image to improve the overall quality of the image.
I've used various different functions in this algorithm- Cross-bilateral Filter, Bilateral Filter, Enhancing the Light and Detecting the shadows.
Firstly, I created the filtered versions of both the images using the cross-bilateral filter.
Then I created a shadow-mask using the filtered images using thresholding.
Finally, combining the two images with different weights to each, we get the final image.
Note - Here I've created my own functions. Although, we can also use the functions available in different libraries.
Real OR Fake
This algorithm deals with the detection of the originality of a specific object or person based on the image inputs.
We can do this using various approaches based on the information we have about the image. Here I've used the object boundaries and the number of heads Ravana has in any specific image.
The basic function is to detect the boundaries of the figure using binary thresholding and contour detection.
I've detected the various possible contours possible in the image and then kept the shape with the maximum area as the contour of the figure.
Then I've checked the lower bounds of the contour of the figure and detected the number of heads on each side of the face, which reveals if the image is real or fake.