フィルターのクリア

How can I apply a non-built in function to an image for quantification?

4 ビュー (過去 30 日間)
oumi k
oumi k 2022 年 3 月 23 日
コメント済み: oumi k 2022 年 3 月 24 日
THIS ERROR APPEARS : Assignment has more non-singleton rhs dimensions than non-singleton subscripts Error in TP2_script (line 13) I(i,j)=quant;

回答 (2 件)

Walter Roberson
Walter Roberson 2022 年 3 月 23 日
quant= [I(i,j)*(fmax-fmin)/q]/N-1;
  2 件のコメント
oumi k
oumi k 2022 年 3 月 23 日
Thank you for your answer. Apparently I now have a new error with this line in the function
Error using Quant_gray --> if I(i,j)~= fmax; %I(i,j) not equal to fmax
Not enough input arguments.
Can you please advise?
oumi k
oumi k 2022 年 3 月 23 日
The image is all entirely black even with this modification.

サインインしてコメントする。


Image Analyst
Image Analyst 2022 年 3 月 23 日
Try this. You might want to reexamine your formula though.
% I=imread('irm2.jpg');
grayImage=imread('cameraman.tif');
[rows, columns, numberOfColorChannels] = size(grayImage);
subplot(1, 2, 1);
imshow(grayImage);
title('Input Image')
impixelinfo
axis('on', 'image')
if numberOfColorChannels == 3
errordlg('Error: program only works for gray scale images, not color images');
return
end
N=16 %niveau de quantification change to 4,8,16...128
fmin=min(min(grayImage)) % for 2D matrix of data (vector utilisation)
fmax=max(max(grayImage))
q=(fmax-fmin)/N % pas de quantification
% Convert to floating point
grayImage = double(grayImage);
for row = 1 : rows
for col = 1 : columns
quant = Quant_gray(grayImage, N, q, fmax, fmin, row, col);
grayImage(row, col) = quant;
end
end
% Show resulting output image.
subplot(1, 2, 2);
imshow(grayImage, []);
title('Output Image')
impixelinfo
%===================================================================================================================
function [quant] = Quant_gray(I, N, q, fmax, fmin, row, col)
if I(row, col) ~= fmax %I(i,j) not equal to fmax
quant= [I(row, col) * (fmax-fmin)/q] / N - 1;
quant= floor(quant);
else
quant = N-1; % I(i,j)=fmax
end
end
  3 件のコメント
Image Analyst
Image Analyst 2022 年 3 月 24 日
I suspect this
quant= [I(row, col) * (fmax-fmin)/q] / N - 1;
quant= floor(quant);
is always giving 0. Not sure what you're doing but you might try discretize().
oumi k
oumi k 2022 年 3 月 24 日
Yes the problem is here. Thank you for your advice I will work on it.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by