如何找到图像的大小?

时间:2018-04-19 18:00:06

标签: image matlab image-processing matrix

我需要将图像的大小作为变量。 这是我试过的:

SecondException

如何获得图片的大小?

2 个答案:

答案 0 :(得分:2)

也许这会有所帮助。它将为您提供文件夹中每个图像的大小。

a = dir('C:\example\Desktop\imagefolder\*.png');
numberofImages = length(a);
for i=1:numberofImages
    img = imread(a(i).name);
    sizeofImage{i} = size(img)
end

然后,您可以使用以下表示法访问图像的大小:

sizeofImage{1}

对于图像400x400,将返回类似的内容:

ans = 
   400 400 3

答案 1 :(得分:1)

您需要一组数字才能进入C,而from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, ForeignKey, create_engine from sqlalchemy.orm import relationship, sessionmaker, scoped_session from sqlalchemy.orm.session import object_session import time from threading import Thread Base = declarative_base() engine = create_engine('sqlite:///test.sqlite', echo=True) conn = engine.connect() session = scoped_session(sessionmaker(bind=engine)) # uncommenting this line shares a single session across all the threads # session = session() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) b = relationship("B", back_populates="a") c = relationship("C", back_populates="a") class B(Base): __tablename__ = 'b' id = Column(Integer, primary_key=True) a = relationship("A", back_populates="b") a_id = Column(Integer, ForeignKey('a.id')) def __init__(self, a): self.a = a class C(Base): __tablename__ = 'c' id = Column(Integer, primary_key=True) a = relationship("A", back_populates="c") a_id = Column(Integer, ForeignKey('a.id')) def __init__(self, a): self.a = a def loop_add_cls(cls): def func(): for i in range(10): time.sleep(1) session.add(cls(a=a)) session.commit() return func Base.metadata.create_all(engine) a = A() session.add(a) session.commit() Thread(target=loop_add_cls(B)).start() Thread(target=loop_add_cls(C)).start() 已经为您提供了一个数字。只需zeros(或使用方括号)和图片数量即可完成:

size

虽然我强烈建议你停止在你的项目上工作,然后开始在MATLAB上上课,请阅读一本书或take the MathWorks own tutorial,因为这与MATLAB的基本相同。由于MATrix LABoratory是关于矩阵的,horzcat很重要。