フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Exclude point from my regression

1 回表示 (過去 30 日間)
valerio auricchio
valerio auricchio 2020 年 11 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi I'm doing regression with this code
I=imread('Immage.bmp')
%find the min and max
minimo= min(I(:))
massimo=max(I(:))
[r, c] = find(I>=224 & I<=225)
coefficients = polyfit(r, c, 1);
%xFit = x; % Option 1 : same number of points as the training set.
xFit = linspace(min(r), max(r), 2000); % Option 2 : lots of points, and not just where the training points are.
yFit = polyval(coefficients, xFit);
imshow(I)
hold on
plot(r, c, 'r*', 'LineWidth', 2, 'Markersize', 6)
hold on;
plot(xFit, yFit, 'm-', 'LineWidth', 5)
hold on;
line([1,2448],[1024,1024]);
'r' and 'c' are two vector thaht rappresent the coordinates (X,Y) of the pixel. I want to remove the pixel where the intensity is lower than a parameter. How can i do that?
  2 件のコメント
KSSV
KSSV 2020 年 11 月 5 日
You cannot remove that pixle.......but you can replace that with some other value.
valerio auricchio
valerio auricchio 2020 年 11 月 5 日
I do not want to remove pixel i want to exclude them form the regression

回答 (1 件)

KSSV
KSSV 2020 年 11 月 5 日
編集済み: KSSV 2020 年 11 月 5 日
Let I be your m*n image.
[m,n] = size(I) ;
[X,Y] = meshgrid(1:n,1:m) ;
[r, c] = find(I>=224 & I<=225) ;
% Get the pixel values at r, c
p = interp2(X,Y,I,r,c) ; % if it throws error comvert I into double
% Let pi be pixel values you want to remove
idx = p == pi ; % idx = abs(p-pi)<=10^-3
r(idx) = []; c(idx) =[] ; % remove those points which have pi pixel
  13 件のコメント
valerio auricchio
valerio auricchio 2020 年 11 月 6 日
range 170 180
KSSV
KSSV 2020 年 11 月 6 日
I am not getting any error....the given code is working fine.

この質問は閉じられています。

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by