Image differencing / Change detection : Implementation problem
Hi all, I am attempting to create an image differencing script using scikit-image. Essentially, I would like to subtract one image from the other. Since the images are numpy arrays it should be possible to calculate the difference between images and then plot the result as an image. However, my result is consistently an array with a singular value, i.e. values are all the same. Below is a sample script using the built-in skimage imagery data. In this case the output is an array where all values are 156. Interestingly, when I add the image objects, it works. Any help would be much appreciated. import skimage from skimage import io, data import matplotlib.pyplot as plt import numpy as np im = data.moon() im2 = data.moon() + 100 im3 = im -im2 plt.imshow(im3, interpolation= 'nearest')
Hi Jared, The output of your code is correct. I'm not sure what kind of behaviour you are looking for. im = data.moon()
im2 = data.moon() + 100 im3 = im -im2
Both `im`, 'im2` and, therefore, `im3` are arrays of uin8. Basically, im - im2 = moon() - (moon() + 100) = -100 = (underflows because of uint8) = 256-100 = 156. For im + im2 = moon() + (moon() + 100) = 2*moon() + 100 = {moon() is not single valued} = something varying. If this doesn't anwsers your question, could you elaborate more on it? Cheers, Egor воскресенье, 26 июня 2016 г., 5:21:42 UTC+3 пользователь Jared Lewis написал:
Hi all,
I am attempting to create an image differencing script using scikit-image. Essentially, I would like to subtract one image from the other. Since the images are numpy arrays it should be possible to calculate the difference between images and then plot the result as an image. However, my result is consistently an array with a singular value, i.e. values are all the same. Below is a sample script using the built-in skimage imagery data. In this case the output is an array where all values are 156. Interestingly, when I add the image objects, it works. Any help would be much appreciated.
import skimage from skimage import io, data import matplotlib.pyplot as plt import numpy as np
im = data.moon() im2 = data.moon() + 100 im3 = im -im2
plt.imshow(im3, interpolation= 'nearest')
participants (2)
-
Egor Panfilov
-
Jared Lewis