How to design convolution kernals?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jiby
am 13 Okt. 2022
Kommentiert: Jiby
am 15 Okt. 2022
Design convolution kernels
i. Translating image
ii. Invert the image
iii. Rectify the image
iv. Subtract from each pixel the value of the mean of the contiguous surrounding pixels.
v. Highlight vertical edges by taking a derivative in the horizontal direction only.
vi. Embossing effect below and to the right of image features.
vii. Flip the image left to right.
viii. Make a single kernel to cascade operations i) and ii) above.
Invent and implement and algorithm to determine the amount and direction of shift between the images in ct.jpg and ctshift.jpg.
Please provide a listing of your code, and the shift in both i and j.
6 Kommentare
Akzeptierte Antwort
Image Analyst
am 15 Okt. 2022
Not sure what invert and rectify means. Does it mean spatially or in intensity?
For translate just have a 1-@ or 2-D kernel of a delta function, in other words an array that is all zeros except there is a 1 NOT at the very center of the array but offset some distance from it. The distance away from the center specifies the translation and the direction determines the direction of the shift.
For iv, you can get the mean of all pixels in a 3x3 window with ones(3)/9. To get the mean of the surrounding pixels it would be 1's just in the 8 pixels in the ring (don't include the center) but then you have to divide by 8 instead of 9. So the kernel to subtract that from 1 would be a 3x3 window with 1 in the middle minus that kernel with 1/8's in it.
4 Kommentare
Image Analyst
am 15 Okt. 2022
I don't know how to either
- invert the intensity of pixels, or
- invert/flip the image right-to-left, or top-to-bottom
using just convolution alone. Of course you can flip the image spatially using fliplr or flipud, and you can invert the intensity just by subtracting the image from a constant, such as the white value of 255 for a uint8 image or 65535 for a 16 bit image.
Normally for some kernel, in general, the output value will be a floating point number (unless all the kernel numbers were integers). So, for whatever reason conv2 won't cast unsigned integer image variables into double -- you have to do that yourself while or before calling conv2. With imfilter it probably does that for you internally. Then, imfilter casts it back to the original unsigned integer class upon returning the result to you. Also, imfilter does not flip the kernel like convolution does, so it's more like a correlation than a convolution because of that. But correlation and convolution are the same except that convolution flips the kernel. There are theoretical, mathematical reasons for that. Also, imfilter has a lot more choices for how to handle the edge situation, like when the sliding window is in a location where part of the window is "off the image".
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Red finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!