top- hat transform for signal processing
显示 更早的评论
Hello, I want to know how to write matlab code for top-hat and bottom-hat (morphological operation) for signal processing??
回答(2 个)
I know imtophat() and imbothat() should work for 1-D signals. They're in the Image Processing Toolbox. Observe:
v = randi(20, 1, 15)
windowWidth = 3;
v2 = imtophat(v, true(1, windowWidth))
The tophat and bottomhat operations are the difference of the source image and the opening/closing of said image with the selected strel. They represent the changes made -- i.e. the objects removed by opening or the holes filled by closing.
If you're trying to write your own, then:
For binary data, they should be equivalent to
outpict = inpict & ~imopen(inpict,se); % tophat
outpict = ~inpict & imclose(inpict,se); % bothat
For numeric data, they are
outpict = inpict - imopen(inpict,se); % tophat
outpict = imclose(inpict,se) - inpict; % bothat
The same should apply for 1D cases. Ultimately, opening and closing operations can be further reduced to a set of routines based on a simple moving-window maximum filter.
2 个评论
Image Analyst
2021-11-26
Of course if they have imopen() then they have the Image Processing Toolbox and can call imtophat() directly. I think you might have meant to use movmin() and movmax() which do not require the Image Processing Toolbox.
DGM
2021-11-26
movmax could be used in the 1D case, but I intentionally was trying to speak generally. To that end, it's worth noting that movmax() is something that I still consider relatively new (though I guess it's in OP's version).
Yes, it's reasonable to assume the availability of included tools once IPT is being used, but I had to consider two things. I don't know if this is just another "how do I reinvent the wheel for my homework problem" question. Additionally, I didn't want to pseudocode something using generic function names like "open()" or "close()" knowing that someone would actually copy and paste them and run them blind.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!