在MATLAB中使用colfilt函数时出错

时间:2016-12-06 16:36:03

标签: matlab image-processing

function vars = nonlinear(f)
p = colfilt(f , [3 , 3] ,'sliding',@vimabsolute);
imshow (p);
end

function v = vimabsolute(A)
[a ~] = size(A);
q =rand(1,a);
v = q * A;
end

B = colfilt(A,[M N],'sliding',FUN) rearranges each M-by-N sliding
neighborhood of A into a column in a temporary matrix, and then applies
the function FUN to this matrix. FUN must return a row vector containing
a single value for each column in the temporary matrix. (Column
compression functions such as SUM return the appropriate type of
output.) colfilt then rearranges the vector returned by FUN into a
matrix of the same size as A.

我只是想尝试colfilt函数是否可行。正如文档中提到的,A是一个9乘MN的矩阵,但运行它会返回错误消息

Error  using * 
MTIMES does not fully support integer classes. At least one input must be scalar

我做错了什么?

1 个答案:

答案 0 :(得分:0)

虽然mtimes的文档似乎暗示它支持整数数据类型,但是您收到的错误信息显然没有。您的变量ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(messageBrokerUrl); try { connection = connectionFactory.createConnection(); connection.start(); this.session = connection.createSession(this.transacted, ackMode); Destination adminQueue = this.session.createQueue(messageQueueName); this.replyProducer = this.session.createProducer(null); this.replyProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); //Set up a consumer to consume messages off of the admin queue MessageConsumer consumer = this.session.createConsumer(adminQueue); consumer.setMessageListener(this); } catch (JMSException e) { log.error("Error al configurar servicio de colas MQ. " + e.getMessage()); } 的类型为double,但您的矩阵q是一个整数类型,可能是大多数图像的uint8。我不确定你希望从你的函数得到什么结果,但看起来你需要将A强制转换为A来执行操作。您有以下几种选择:

double