Latest YouTube Video
Saturday, June 24, 2017
Eskimos vs Lions Live Free
from Google Alert - anonymous http://ift.tt/2t4nAlm
via IFTTT
Edmonton vs BC Live Stream
from Google Alert - anonymous http://ift.tt/2t8nav1
via IFTTT
Ryan Bader vs Phil Davis Live Free
from Google Alert - anonymous http://ift.tt/2tIeCbA
via IFTTT
[live] Bellator 180 Live stream FREE
from Google Alert - anonymous http://ift.tt/2t8lzFG
via IFTTT
Orioles Video: Trey Mancini jacks 2-run opposite-field homer to pad lead in 8-3 win at Rays (ESPN)
via IFTTT
Fox[live] Down vs Cavan LIVE stream 2017
from Google Alert - anonymous http://ift.tt/2t7oLkm
via IFTTT
Mexico vs Russia Live Free
from Google Alert - anonymous http://ift.tt/2u0CTsp
via IFTTT
I have a new follower on Twitter
Matthew Kindel
Husband and Father, and proud defender of liberty; tipping the scales of justice in favor of those accused.
Land O' Lakes/NPR, FL, USA
http://t.co/Vhq4sUf0n1
Following: 18778 - Followers: 20677
June 24, 2017 at 12:00PM via Twitter http://twitter.com/MatthewKindel
Anonymous user a23c7a
from Google Alert - anonymous http://ift.tt/2t5MhyF
via IFTTT
Panel Discussion Never Precious: Anonymous Design in Canada With Greg Durell, Joel Derksen ...
from Google Alert - anonymous http://ift.tt/2t5GBV6
via IFTTT
32TB of Windows 10 Internal Builds & Source Code Leaked Online
from The Hacker News http://ift.tt/2t1HIEU
via IFTTT
The Anexo in Northern California: An Alcoholics Anonymous-Based Recovery Residence in Latino ...
from Google Alert - anonymous http://ift.tt/2t5EVec
via IFTTT
Markarian s Chain to Messier 64
Friday, June 23, 2017
Orioles have allowed 5 or more runs in 20 straight games, tying 1924 Phillies for longest streak in Modern Era (ESPN)
via IFTTT
interface stubbing for anonymous implementations
from Google Alert - anonymous http://ift.tt/2s0Pr6T
via IFTTT
Orioles reinstate P Darren O'Day (right shoulder strain) from 10-day DL; P Gabriel Ynoa optioned to Triple-A Norfolk (ESPN)
via IFTTT
Anonymous Radio
from Google Alert - anonymous http://ift.tt/2szUIRf
via IFTTT
Gamblers anonymous 12 steps printable
from Google Alert - anonymous http://ift.tt/2t0hjr2
via IFTTT
Academy Adventures Season 2!
from Google Alert - anonymous http://ift.tt/2tXCSFF
via IFTTT
Anonymous Donation Adorns Creighton's Main Street, Park
from Google Alert - anonymous http://ift.tt/2s4vkj5
via IFTTT
Anonymous - Chef de Cuisine
from Google Alert - anonymous http://ift.tt/2szbHTH
via IFTTT
Company Statement: Conclusion of Independent Investigation into Allegations made by ...
from Google Alert - anonymous http://ift.tt/2tWFCDw
via IFTTT
Two British Men Arrested For Hacking Microsoft
from The Hacker News http://ift.tt/2sxjEZK
via IFTTT
Free anonymous proxy with flash
from Google Alert - anonymous http://ift.tt/2sXMYsY
via IFTTT
Anonymous uncensored seach engines
from Google Alert - anonymous http://ift.tt/2tVuHd8
via IFTTT
(23/06/2017) ==$C free bitcoin anonymous : vyplati se bitcoin mining
from Google Alert - anonymous http://ift.tt/2rJiyXP
via IFTTT
New GhostHook Attack Bypasses Windows 10 PatchGuard Protections
from The Hacker News http://ift.tt/2sXJiHP
via IFTTT
[FD] OffensiveCon Berlin 2018 Call for Papers
Source: Gmail -> IFTTT-> Blogger
Solstice Conjunction over Budapest
Thursday, June 22, 2017
Anonymous Juror Says Cosby "Paid His Price"
from Google Alert - anonymous http://ift.tt/2tURvJT
via IFTTT
Dual Recovery Anonymous Support Group Meeting
from Google Alert - anonymous http://ift.tt/2sWYWmQ
via IFTTT
Enable user submission limit for anonymous users
from Google Alert - anonymous http://ift.tt/2s1cGsn
via IFTTT
Do not rely on hardcoded strings as an API for recording anonymous user file uploads in the session
from Google Alert - anonymous http://ift.tt/2tziUBL
via IFTTT
Digital Addiction Anonymous
from Google Alert - anonymous http://ift.tt/2sZP5ND
via IFTTT
Become an anonymous sperm donor
from Google Alert - anonymous http://ift.tt/2tTL9ur
via IFTTT
"Devil's Advocate" by Anonymous Henchmen
from Google Alert - anonymous http://ift.tt/2t0bCJR
via IFTTT
Drupal Core - Multiple Vulnerabilities - SA-CORE-2017-003
from Google Alert - anonymous http://ift.tt/2sFHpNM
via IFTTT
Ravens: John Harbaugh hangs inspirational message from goal posts to honor late family friend and motivate players - Jamison Hensley (ESPN)
via IFTTT
ALCOHOLICS ANONYMOUS 208-235-1444 AL-ANON 208-232-2692
from Google Alert - anonymous http://ift.tt/2sY7KcI
via IFTTT
IN RE: NASIR A. (Anonymous).
from Google Alert - anonymous http://ift.tt/2txGRJS
via IFTTT
No, WannaCry Is Not Dead! Hits Honda & Traffic Light Camera System
from The Hacker News http://ift.tt/2txLK5I
via IFTTT
Orioles: Buck Showalter will miss Thursday vs. Indians to attend birth of his first grandchild in Dallas; to return Friday at Rays (ESPN)
via IFTTT
[FD] SEC Consult SA-20170622-0 :: XXE, SQLi, XSS & local file disclosure in Cisco Prime Infrastructure
Source: Gmail -> IFTTT-> Blogger
Brutal Kangaroo: CIA-developed Malware for Hacking Air-Gapped Networks Covertly
from The Hacker News http://ift.tt/2twxV7p
via IFTTT
Free anonymous proxy surf
from Google Alert - anonymous http://ift.tt/2sTUG7B
via IFTTT
Critical RCE Flaw Found in OpenVPN that Escaped Two Recent Security Audits
from The Hacker News http://ift.tt/2sYhSSy
via IFTTT
Flying Around The Eclipse Shadow
from NASA's Scientific Visualization Studio: Most Recent Items http://ift.tt/2twfqAf
via IFTTT
Anonymous Bullying Tip Form
from Google Alert - anonymous http://ift.tt/2sXR0lz
via IFTTT
Northern Summer on Titan
Wednesday, June 21, 2017
Free Web Proxy
from Google Alert - anonymous http://ift.tt/2tPwbWp
via IFTTT
Service that unmasks anonymous site visitors raises privacy concerns
from Google Alert - anonymous http://ift.tt/2sqKgLQ
via IFTTT
Leaks & Anonymous Sources Dominate Coverage of Trump/Russia Investigations
from Google Alert - anonymous http://ift.tt/2ttPQMe
via IFTTT
How to track anonymous questions on tumblr using google chrome
from Google Alert - anonymous http://ift.tt/2spLeYE
via IFTTT
WebSites Found Collecting Data from Online Forms Even Before You Click Submit
from The Hacker News http://ift.tt/2tN1i4y
via IFTTT
NSA Opens Github Account — Lists 32 Projects Developed by the Agency
from The Hacker News http://ift.tt/2rP5pRm
via IFTTT
A Sundial that Shows Solstice
Tuesday, June 20, 2017
Orioles Video: Manny Machado crushes 2 homers into the left-field seats to power 6-5 win over Indians (ESPN)
via IFTTT
Anonymous sharing links for folders cease to work
from Google Alert - anonymous http://ift.tt/2sohXOl
via IFTTT
Trappin Anonymous Live Show @ SOBS TONIGHT by Trappin Anonymous
from Google Alert - anonymous http://ift.tt/2rAuR9a
via IFTTT
Get Link for Anonymous Users from Within Teams
from Google Alert - anonymous http://ift.tt/2tL7VET
via IFTTT
I have a new follower on Twitter
Renea Hanks💞
Business Services Consultant, Technology, Real Estate and Scent Marketing/Manufacturing
Texas, USA
https://t.co/MIwrS99NzV
Following: 14120 - Followers: 15232
June 20, 2017 at 05:50PM via Twitter http://twitter.com/reneatinytalks
Exclusive: Upcoming Windows 10 Version May Have Built-in EMET to Boost Security
from The Hacker News http://ift.tt/2sSYM06
via IFTTT
033-Anonymous Purchase Strategies by The Complete Privacy & Security Podcast
from Google Alert - anonymous http://ift.tt/2rA91Cv
via IFTTT
anonymous white grain
from Google Alert - anonymous http://ift.tt/2rNmNG5
via IFTTT
Microsoft to Remove SMBv1 Protocol in Next Windows 10 Version (RedStone 3)
from The Hacker News http://ift.tt/2rzIKEr
via IFTTT
Ravens: John Harbaugh learning to appreciate smaller things in life amid hectic world of football - Jamison Hensley (ESPN)
via IFTTT
[InsideNothing] gumersindo liked your post "[FD] Zend Framework / zend-mail < 2.4.11 Remote Code Execution (CVE-2016-10034)"
|
Source: Gmail -> IFTTT-> Blogger
[Xen-announce] Xen Security Advisory 222 - stale P2M mappings due to insufficient error checking
Source: Gmail -> IFTTT-> Blogger
Theatre Geeks Anonymous Podcast by Ebony and Pamela
from Google Alert - anonymous http://ift.tt/2slziaD
via IFTTT
Justice Department, Glassdoor clash over revealing anonymous reviewers
from Google Alert - anonymous http://ift.tt/2svIveK
via IFTTT
[live] Lions Tour 2017 live Online on FREE
from Google Alert - anonymous http://ift.tt/2tnCRLS
via IFTTT
FREE(TV);; Chiefs vs Lions 2017 Live Online FREE
from Google Alert - anonymous http://ift.tt/2tnb7XO
via IFTTT
A Decade Old Unix/Linux/BSD Root Privilege-Escalation Bug Discovered
from The Hacker News http://ift.tt/2sNRFqf
via IFTTT
Fox[live]Chiefs vs Lions LIVE Rugby stream 2017
from Google Alert - anonymous http://ift.tt/2tn0XWW
via IFTTT
View content access wrongly denied for certain pages for anonymous uses
from Google Alert - anonymous http://ift.tt/2sNL3rV
via IFTTT
[FD] Reflected XSS in WordPress Download Manager could allow an attacker to do almost anything an admin can (WordPress plugin)
Source: Gmail -> IFTTT-> Blogger
[FD] Path traversal in Photo Gallery may allow admins to read most files on the filesystem (WordPress plugin)
Source: Gmail -> IFTTT-> Blogger
[FD] Freeware Advanced Audio Coder (FAAC) multiple vulnerabilities
Source: Gmail -> IFTTT-> Blogger
I have a new follower on Twitter
ImAnAlcoholic
I am a son, brother, husband, friend and an alcoholic, who is proud to be in recovery! https://t.co/U51ktJXZug
https://t.co/VyU7CXnVK2
Following: 2041 - Followers: 9859
June 20, 2017 at 03:02AM via Twitter http://twitter.com/ImAnAlcoholic__
The Massive Stars in Westerlund 1
Monday, June 19, 2017
MLB: Indians' Corey Kluber dominates Orioles with complete-game 3-hitter, strikes out 11 in 12-0 win (ESPN)
via IFTTT
Web Hosting Company Pays $1 Million to Ransomware Hackers to Get Files Back
from The Hacker News http://ift.tt/2sLDQbP
via IFTTT
Orioles: J.J. Hardy has non-displaced fracture of right wrist, says it will be 4-6 weeks before he can resume baseball activities (ESPN)
via IFTTT
Ravens upgraded secondary by signing Tony Jefferson but questions remain along O-line, receive offseason grade of B from Jamison Hensley (ESPN)
via IFTTT
Database of Over 198 Million U.S. Voters Left Exposed On Unsecured Server
from The Hacker News http://ift.tt/2ssEV5f
via IFTTT
Image Difference with OpenCV and Python
In a previous PyImageSearch blog post, I detailed how to compare two images with Python using the Structural Similarity Index (SSIM).
Using this method, we were able to easily determine if two images were identical or had differences due to slight image manipulations, compression artifacts, or purposeful tampering.
Today we are going to extend the SSIM approach so that we can visualize the differences between images using OpenCV and Python. Specifically, we’ll be drawing bounding boxes around regions in the two input images that differ.
To learn more about computing and visualizing image differences with Python and OpenCV, just keep reading.
Looking for the source code to this post?
Jump right to the downloads section.
Image Difference with OpenCV and Python
In order to compute the difference between two images we’ll be utilizing the Structural Similarity Index, first introduced by Wang et al. in their 2004 paper, Image Quality Assessment: From Error Visibility to Structural Similarity. This method is already implemented in the scikit-image library for image processing.
The trick is to learn how we can determine exactly where, in terms of (x, y)-coordinate location, the image differences are.
To accomplish this, we’ll first need to make sure our system has Python, OpenCV, scikit-image, and imutils.
You can learn how to configure and install Python and OpenCV on your system using one of my OpenCV install tutorials.
If you don’t already have
scikit-imageinstalled/upgraded, upgrade via:
$ pip install --upgrade scikit-image
While you’re at it, go ahead and install/upgrade
imutilsas well:
$ pip install --upgrade imutils
Now that our system is ready with the prerequisites, let’s continue.
Computing image difference
Can you spot the difference between these two images?
If you take a second to study the two credit cards, you’ll notice that the MasterCard logo is present on the left image but has been Photoshopped out from the right image.
You may have noticed this difference immediately, or it may have taken you a few seconds. Either way, this demonstrates an important aspect of comparing image differences — sometimes image differences are subtle — so subtle that the naked eye struggles to immediately comprehend the difference (we’ll see an example of such an image later in this blog post).
So why is computing image differences so important?
One example is phishing. Attackers can manipulate images ever-so-slightly to trick unsuspecting users who don’t validate the URL into thinking they are logging into their banking website — only to later find out that it was a scam.
Comparing logos and known User Interface (UI) elements on a webpage to an existing dataset could help reduce phishing attacks (a big thanks to Chris Cleveland for passing along PhishZoo: Detecting Phishing Websites By Looking at Them as an example of applying computer vision to prevent phishing).
Developing a phishing detection system is obviously much more complicated than simple image differences, but we can still apply these techniques to determine if a given image has been manipulated.
Now, let’s compute the difference between two images, and view the differences side by side using OpenCV, scikit-image, and Python.
Open up a new file and name it
image_diff.py, and insert the following code:
# import the necessary packages from skimage.measure import compare_ssim import argparse import imutils import cv2 # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-f", "--first", required=True, help="first input image") ap.add_argument("-s", "--second", required=True, help="second") args = vars(ap.parse_args())
Lines 2-5 show our imports. We’ll be using
compare_ssim(from scikit-image),
argparse,
imutils, and
cv2(OpenCV).
We establish two command line arguments,
--firstand
--second, which are the paths to the two respective input images we wish to compare (Lines 8-13).
Next we’ll load each image from disk and convert them to grayscale:
# import the necessary packages from skimage.measure import compare_ssim import argparse import imutils import cv2 # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-f", "--first", required=True, help="first input image") ap.add_argument("-s", "--second", required=True, help="second") args = vars(ap.parse_args()) # load the two input images imageA = cv2.imread(args["first"]) imageB = cv2.imread(args["second"]) # convert the images to grayscale grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY) grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY)
We load our first and second images,
--firstand
--second, on Lines 16 and 17, storing them as
imageAand
imageB, respectively.
Then we convert each to grayscale on Lines 20 and 21.
Next, let’s compute the Structural Similarity Index (SSIM) between our two grayscale images.
# import the necessary packages from skimage.measure import compare_ssim import argparse import imutils import cv2 # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-f", "--first", required=True, help="first input image") ap.add_argument("-s", "--second", required=True, help="second") args = vars(ap.parse_args()) # load the two input images imageA = cv2.imread(args["first"]) imageB = cv2.imread(args["second"]) # convert the images to grayscale grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY) grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY) # compute the Structural Similarity Index (SSIM) between the two # images, ensuring that the difference image is returned (score, diff) = compare_ssim(grayA, grayB, full=True) diff = (diff * 255).astype("uint8") print("SSIM: {}".format(score))
Using the
compare_ssimfunction from scikit-image, we calculate a
scoreand difference image,
diff(Line 25).
The
scorerepresents the structural similarity index between the two input images. This value can fall into the range [-1, 1] with a value of one being a “perfect match”.
The
diffimage contains the actual image differences between the two input images that we wish to visualize. The difference image is currently represented as a floating point data type in the range [0, 1] so we first convert the array to 8-bit unsigned integers in the range [0, 255] (Line 26) before we can further process it using OpenCV.
Now, let’s find the contours so that we can place rectangles around the regions identified as “different”:
# import the necessary packages from skimage.measure import compare_ssim import argparse import imutils import cv2 # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-f", "--first", required=True, help="first input image") ap.add_argument("-s", "--second", required=True, help="second") args = vars(ap.parse_args()) # load the two input images imageA = cv2.imread(args["first"]) imageB = cv2.imread(args["second"]) # convert the images to grayscale grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY) grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY) # compute the Structural Similarity Index (SSIM) between the two # images, ensuring that the difference image is returned (score, diff) = compare_ssim(grayA, grayB, full=True) diff = (diff * 255).astype("uint8") print("SSIM: {}".format(score)) # threshold the difference image, followed by finding contours to # obtain the regions of the two input images that differ thresh = cv2.threshold(diff, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = cnts[0] if imutils.is_cv2() else cnts[1]
On Lines 31 and 32 we threshold our
diffimage using both
cv2.THRESH_BINARY_INVand
cv2.THRESH_OTSU— both of these settings are applied at the same time using the vertical bar ‘or’ symbol,
|. For details on Otsu’s bimodal thresholding setting, see this OpenCV documentation.
Subsequently we find the contours of
threshon Lines 33-35. The ternary operator on Line 35 simply accommodates difference between the cv2.findContours return signature in OpenCV 2.4 and OpenCV 3, respectively.
The image in Figure 4 below clearly reveals the ROIs of the image that have been manipulated:
Now that we have the contours stored in a list, let’s draw rectangles around the different regions on each image:
# import the necessary packages from skimage.measure import compare_ssim import argparse import imutils import cv2 # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-f", "--first", required=True, help="first input image") ap.add_argument("-s", "--second", required=True, help="second") args = vars(ap.parse_args()) # load the two input images imageA = cv2.imread(args["first"]) imageB = cv2.imread(args["second"]) # convert the images to grayscale grayA = cv2.cvtColor(imageA, cv2.COLOR_BGR2GRAY) grayB = cv2.cvtColor(imageB, cv2.COLOR_BGR2GRAY) # compute the Structural Similarity Index (SSIM) between the two # images, ensuring that the difference image is returned (score, diff) = compare_ssim(grayA, grayB, full=True) diff = (diff * 255).astype("uint8") print("SSIM: {}".format(score)) # threshold the difference image, followed by finding contours to # obtain the regions of the two input images that differ thresh = cv2.threshold(diff, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = cnts[0] if imutils.is_cv2() else cnts[1] # loop over the contours for c in cnts: # compute the bounding box of the contour and then draw the # bounding box on both input images to represent where the two # images differ (x, y, w, h) = cv2.boundingRect(c) cv2.rectangle(imageA, (x, y), (x + w, y + h), (0, 0, 255), 2) cv2.rectangle(imageB, (x, y), (x + w, y + h), (0, 0, 255), 2) # show the output images cv2.imshow("Original", imageA) cv2.imshow("Modified", imageB) cv2.imshow("Diff", diff) cv2.imshow("Thresh", thresh) cv2.waitKey(0)
Beginning on Line 38, we loop over our contours,
cnts. First, we compute the bounding box around the contour using the
cv2.boundingRectfunction. We store relevant (x, y)-coordinates as
xand
yas well as the width/height of the rectangle as
wand
h.
Then we use the values to draw a red rectangle on each image with
cv2.rectangle(Lines 43 and 44).
Finally, we show the comparison images with boxes around differences, the difference image, and the thresholded image (Lines 47-50).
We make a call to
cv2.waitKeyon Line 50 which makes the program wait until a key is pressed (at which point the script will exit).
Next, let’s run the script and visualize a few more image differences.
Visualizing image differences
Using this script and the following command, we can quickly and easily highlight differences between two images:
$ python image_diff.py --first images/original_02.png --second images/modified_02.png
As you can see in Figure 6, the security chip and name of the account holder have both been removed:
Let’s try another example of computing image differences, this time of a check written by President Gerald R. Ford (source).
By running the command below and supplying the relevant images, we can see that the differences here are more subtle:
$ python image_diff.py --first images/original_03.png --second images/modified_03.png
Notice the following changes in Figure 7:
- Betty Ford’s name is removed.
- The check number is removed.
- The symbol next to the date is removed.
- The last name is removed.
On a complex image like a check it is often difficult to find all the differences with the naked eye. Luckily for us, we can now easily compute the differences and visualize the results with this handy script made with Python, OpenCV, and scikit-image.
Summary
In today’s blog post, we learned how to compute image differences using OpenCV, Python, and scikit-image’s Structural Similarity Index (SSIM). Based on the image difference we also learned how to mark and visualize the different regions in two images.
To learn more about SSIM, be sure to refer to this post and the scikit-image documentation.
I hope you enjoyed today’s blog post!
And before you go, be sure to enter your email address in the form below to be notified when future PyImageSearch blog posts are published!
Downloads:
The post Image Difference with OpenCV and Python appeared first on PyImageSearch.
from PyImageSearch http://ift.tt/2rvUoQw
via IFTTT