understanding the matlab code

6 views (last 30 days)
bruno
bruno on 16 Dec 2022
Answered: DGM on 18 Dec 2022
There is a code for an image which does filtering. Can anyone help me understand this code? Besides I want to implement this filtering technique for 1D .mat format data having 2 cols and 6000 rows.
  14 Comments
Walter Roberson
Walter Roberson on 18 Dec 2022
When I look around at papers, the ones I find use transfer learning... which requires a dataset of images to train against. Just using the standard pretrained alexnet is not good enough for the papers that I see.
bruno
bruno on 18 Dec 2022
yes the dataset I be using is MIT BIH and its signal will be converted to images RGB for alexnet input

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 18 Dec 2022
I don't know what "relaxed" median filter is, but you can see how I applied a median filter to images in the attached demos. This is after you've converted your signal to an image.
If you want to filter your 1-D signal before you convert it into an image, then you can use medfilt1, but I'm not sure how you would use that in the whole "relaxed" version of median filter (since I don't know what it is).
Alexnet takes 227x227 RGB images. What features of your spectral image do you plan on measuring? And how do you plan on inserting them into the RGB image?
  9 Comments
Image Analyst
Image Analyst on 18 Dec 2022
I agree with DGM in the comment above. The description is very confusing, and it's not only due to it being (obviously) written by a non-native English speaker. It's ambiguous, confusing, contradictory, and basically indecipherable. w is not defined, fs is not defined, m is not defined, Step 2 is gibberish, step 4 seems completely unnecessary, "compared" in Step 6 is not defined, and the criteria in step 8 are not listed.
DGM
DGM on 18 Dec 2022
Regarding the Hamza paper, without institutional access, I'm not going to spend $40 to find out what exactly they're doing. I trust that the Hamza paper is probably a better reference than the prior student paper or algo.pdf, but that's just an assumption.
Remove the average of 500 samples from each sample obtained by ECG to avoid unwanted noise signals in the entering ECG waveform. The signal’s baseline amplitude is reduced to zero due to this action.
To me, that seems like the baseline reduction is done with a box averaging filter instead of a median filter.
fk = ones(500,1)/500; % a box averaging filter kernel (assuming data is a column vector)
xavg = conv(x,fk,'same'); % local average of 500 samples
y = x-xavg; % remove baseline
The filter is tuned to allow low-frequency impulses while attenuating the high frequencies contained in the erratic ECG signal to minimize the noise of the high-frequency components. The high pass filter allows high frequencies while attenuating low frequencies to minimize low-frequency noise.
I'm not sure what filters you're intended to use for this part or what's canonically appropriate for ECG processing.
denoising is crucial to predict anomalies more accurately. Denoising of the ECG signal is performed using a relaxed median filter.
This is kind of the crux of the matter.
I suppose I could write something based on my vague understanding of what a relaxed median filter is, but I might be wrong in that regard.
I have an unpublished 2D adaptive median filter implementation that probably would work, but I'm pretty sure it's going to be dependent on some other things you might not have.

Sign in to comment.


DGM
DGM on 18 Dec 2022
I'm just going to throw this out there. See the attached file. I don't know if it's correct WRT the Hamza paper, but it seems to be some sort of plausible noise filter. I implemented this as a 2D filter. If you only need 1D, you might be able to use it as-is, but I haven't tested that. I'm just more used to dealing with 2D cases.
inpict0 = imread('cameraman.tif');
inpict = imnoise(inpict0,'salt & pepper',0.1);
outpict = rmedfilt(inpict,5);
imshow(inpict)
imshow(outpict)
I guess it works, but it's not very good. It doesn't take much noise to break it. Compare to an adaptive median filter:
Maybe I'm missing something.

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!