首页 \ 问答 \ 在Matlab中从文件夹中读取多个图像的问题(The issue of reading multiple images from a folder in Matlab)

在Matlab中从文件夹中读取多个图像的问题(The issue of reading multiple images from a folder in Matlab)

我有一组位于文件夹中的图像,我正在尝试读取这些图像并将其名称存储在文本文件中。 图像的顺序非常重要。

我的代码如下:

imagefiles = dir('*jpg');
nfiles = length(imagefiles);    % Number of files found
%*******************
for ii=1:nfiles
    currentfilename = imagefiles(ii).name;
    % write the name in txt file
end

按以下顺序存储在文件夹中的图像: {1,2,3,4,100,110}

Matlab读取和写入图像序列的问题为{ 1,100,110,2,3,4} 。 这不是正确的顺序。

怎么能克服这个?


I have a set of images located in a folder and I'm trying to read these images and store their names in text file. Where the order of images is very important.

My code as follow:

imagefiles = dir('*jpg');
nfiles = length(imagefiles);    % Number of files found
%*******************
for ii=1:nfiles
    currentfilename = imagefiles(ii).name;
    % write the name in txt file
end

The images stored in the folder in the following sequence : {1,2,3,4,100,110}.

The problem that Matlab read and write the sequence of images as { 1,100,110,2,3,4}. Which is not the correct order.

How can this be overcome?


原文:https://stackoverflow.com/questions/30479446
更新时间:2022-07-01 18:07

最满意答案

首先,是的,您可以使用普通按钮进行幻灯片输入和输出面板。 现在,该怎么做?

首先为您的面板创建一个单独的布局xml文件,例如“ panel.xml ”。

现在在你的游戏xml文件中使用include标签并设置它的重力:TOPvisibility:GONE并将它的id设置为panel ie

android:id="@+id/panel";

现在,在项目res文件夹中创建一个名为“ anim ”的文件夹。 这里创建两个xml文件slide_in.xml和slide_out.xml这些xml苍蝇将帮助您获得幻灯片的进出效果。 这些xml文件的代码如下

slide_in.xml:

<?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
     android:fromYDelta="-100%p" 
     android:toYDelta="0%p"
     android:duration="3000"/>

slide_out.xml:

<?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
     android:fromYDelta="0%p" 
     android:toYDelta="-100%p"
     android:duration="3000"/>

现在,构建幻灯片放入和退出面板所需的所有内容都已准备就绪。

实现:

注意:维护一个布尔变量isPanelVisible以检查面板的可见性状态。

为我们包含在游戏xml文件中的panel.xml创建两个Animation类对象slideInslideOut和一个View类对象面板 ,然后像这样初始化它们:

Animation slideIn= AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_in);
Animation slideOut= AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_out);
View panel = findViewById(R.id.panel);

现在当用户点击按钮以显示onClickListener()方法内的幻灯片放入和退出面板时,执行以下操作:

if(isPanelVisible){
    isPanelVisible = false;
    panel.startAnimation(slideOut);
    panel.setVisibility(View.Gone);
} else{
    isPanelVisible = true;
    panel.startAnimation(slideIn);
    panel.setVisibility(View.Visible);
}

First of all yes you can use normal button for your slide in & out panel. Now, how to do it?

First of all create a separate layout xml file for you panel e.g. "panel.xml".

Now use the include tag in your game xml file and set it's gravity : TOP and visibility : GONE and set it's id to panel i.e.

android:id="@+id/panel";

Now create a folder named "anim" inside your projects res folder. Here create two xml files slide_in.xml & slide_out.xml these xml flies will help you in getting the slide in & out effect. Code for these xml file is as follow

slide_in.xml:

<?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
     android:fromYDelta="-100%p" 
     android:toYDelta="0%p"
     android:duration="3000"/>

slide_out.xml:

<?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
     android:fromYDelta="0%p" 
     android:toYDelta="-100%p"
     android:duration="3000"/>

Now all the things required to build your slide in & out panel are ready.

IMPLEMENTATION:

NOTE: maintain a boolean variable isPanelVisible to keep check of visibility state of the panel.

Create two Animation class object slideIn & slideOut and one View class object panel for the panel.xml which we included in the game xml file, then initialize them like this:

Animation slideIn= AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_in);
Animation slideOut= AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_out);
View panel = findViewById(R.id.panel);

Now when the user clicks on the button to show the slide in & out panel inside the onClickListener() method do something like this:

if(isPanelVisible){
    isPanelVisible = false;
    panel.startAnimation(slideOut);
    panel.setVisibility(View.Gone);
} else{
    isPanelVisible = true;
    panel.startAnimation(slideIn);
    panel.setVisibility(View.Visible);
}

相关问答

更多
  • 我自己找到了解决方案,即使这对于演出来说不是最佳的。 只需添加: android:clipChildren="false" 到RelativeLayout(或者你有的任何布局)。 这有2个效果(可能更多,这是对我感兴趣的两个): - ViewGroup不剪辑他的孩子的图画(显而易见) - ViewGroup在考虑考虑时考虑与脏区域交叉(无效)哪些孩子重绘 我挖掘了关于无效的视图代码。 这个过程如下所示: 一个视图本身无效,它通常绘制的区域(一个矩形)变成了一个“脏区域”被重绘 视图告诉其父(某种ViewG ...
  • 您应该使用button.setOnClickListener(this)而不是button.setOnTouchListener(this),并且该类应该实现OnClickListener。 如果你仍然需要处理onTouch(向上和向上),你可以自己处理背景设置。 public boolean onTouch( View button, MotionEvent theMotion ) { switch ( theMotion.getAction() ) { case MotionEve ...
  • 更改 actionBar.setDisplayShowHomeEnabled(true); 至 actionBar.setDisplayShowHomeEnabled(false); 并使用ImageView显示ActionBar左侧的垂直线 change actionBar.setDisplayShowHomeEnabled(true); to actionBar.setDisplayShowHomeEnabled(false); and use ImageView for showing the ...
  • 在dp中给你的自定义视图添加一个尺寸并不容易。 然后您可以在设计模式下看到您的布局。 然后使用onSizeChanged来找出画布的大小。 onMeasure通常在画布的大小取决于运行时间值时使用,例如游戏的结果或加载项的数量等。 这是一个可以工作的例子: @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMea ...
  • 所以,我可以通过两种方式完成: 听取整个列表上的滑动,找出刷过的行,并显示/隐藏正确行的按钮。 听取每行的滑动,并显示/隐藏该行的按钮。 现在您正在列表中设置侦听器,但尝试应用显示/隐藏适配器中附加的按钮。 在某种程度上,你正在做每个解决方案的一半。 有了你所拥有的,我建议你选择#2。 在TransactionAddDropViewHolder ,您需要在行布局中获取对根View的引用,因此我们可以将OnSwipeTouchListener设置为它。 public static final class Tr ...
  • 首先,是的,您可以使用普通按钮进行幻灯片输入和输出面板。 现在,该怎么做? 首先为您的面板创建一个单独的布局xml文件,例如“ panel.xml ”。 现在在你的游戏xml文件中使用include标签并设置它的重力:TOP和visibility:GONE并将它的id设置为panel ie android:id="@+id/panel"; 现在,在项目res文件夹中创建一个名为“ anim ”的文件夹。 这里创建两个xml文件slide_in.xml和slide_out.xml这些xml苍蝇将帮助您获得幻 ...
  • Button btn = new Button(this); btn.setText("Button"); mainActivity_layoutView.addView(btn); 这应该做到这一点。 Button btn = new Button(this); btn.setText("Button"); mainActivity_layoutView.addView(btn); That should do it.
  • 首先,我不确定是否可以为视图扩展RelativeLayout设置android:text 。 如果有可能在TextView实现中这样做: final Resources.Theme theme = context.getTheme(); a = theme.obtainStyledAttributes(attrs, com.android.internal.R.styleable.TextView, defStyleAttr, defStyleRes); text = a.getText(attr); 所 ...
  • 自定义视图对某些情况很有用: 在视觉上创造一些非平凡的东西 - 这意味着你想要自己画一些东西到屏幕上,例如图形。 获得性能 - 这可能是游戏的主要原因 - 布局在深度嵌套时可能会对性能造成沉重的影响(充气,在彼此内部布局多个视图,在布局相互重叠时过度绘制),您可以通过绘制自己来解决这些问题使用自定义视图到屏幕。 此外,使用自定义视图,您可以使用GPU直接在屏幕上绘制内容,并具有硬件加速操作的优势。 有时执行复杂的布局,自动调整到不同的设备大小是使用xml布局的非平凡/不可能的任务,在自定义视图中,您可以创建 ...
  • 如果你检查你的LogCat输出,你会发现一个错误,说你必须在你的布局中指定layout_width和layout_height。 写道: 它应该工作。 if you check your LogCat outp ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)