matlab中 执行图像读取成向量的程序,其中的部分问题

介绍Semantic-FusionGAN用于半监督卫星图像分类的论文及其实现代码,此方法在EuroSAT数据集上进行验证,利用TensorFlow和Python实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇论文:

# SFGAN: Semantic Fusion GAN for semi-supervised learning

Code for paper [**Semantic-Fusion GANs for Semi-Supervised Satellite Image Classification**](https://ieeexplore.ieee.org/abstract/document/8451836/) accepted in the International Conference on Image Processing (**ICIP**) to be held in *Athens, Greece* in October, 2018.

Code is **available now**.

## Requirements
1. Tensorflow 1.5
2. Python 3.5

## Instructions
1. First download the [EuroSAT](http://madm.dfki.de/files/sentinel/EuroSAT.zip) data set and extract the images.
2. Run the file_reader.m to convert the images into a .mat file. This will be used as input for training the network.
3. Run sfgan_train_eval.py to train the network.

N.B. Python 3 is recommended for running this code as the batching gives errornoues results with lower versions of Python. Haven't tried with other versions of Tensorflow.

## Citation
If you use this code for your research, please cite our [paper](https://ieeexplore.ieee.org/abstract/document/8451836/)
```
@inproceedings{roy2018semantic,
  title={Semantic-Fusion Gans for Semi-Supervised Satellite Image Classification},
  author={Roy, Subhankar and Sangineto, Enver and Sebe, Nicu and Demir, Beg{\"u}m},
  booktitle={2018 25th IEEE International Conference on Image Processing (ICIP)},
  pages={684--688},
  year={2018},
  organization={IEEE}
}
```
A commented version of the code will be updated soon.

matlab中 执行图像读取成向量的程序:UCMERCED数据集上操作时 有些图片大小不是256*256,比如airplane55是256*253导致出错reshape语句。后来

clear;
clc;
%load('train_32x32.mat');
%%

%img_size = 64;%原來大小
img_size = 256;
num_channels = 3;
dirs_in_path = dir('./EuroSAT/');
X_img = zeros(img_size, img_size, num_channels, 0);
Y_lab = zeros(0, 1);
test_train_ratio = 0.8;

for i=3:23
    dir_path = strcat('./EuroSAT/', dirs_in_path(i).name, '/');
    disp(dir_path);
    files_in_dir = dir(dir_path);
    fprintf('Reading files in %s \n', dir_path);
    disp(size(files_in_dir, 1));
    for j=3:size(files_in_dir, 1)
        file_path = strcat(dir_path, files_in_dir(j).name);
        img = imread(file_path);
        img = imresize(img,[256,256]);%原来的ucmerced中airplane55.tif 256*253的大小,导致出了问题。
        %disp(img);
        img = reshape(img, [img_size, img_size, num_channels, 1]);
        X_img = cat(4, X_img, img);
        Y_lab = cat(1, Y_lab, (i-3));
        imgSize = size(img);
        %disp(imgSize);
    end
end

num_examples = size(Y_lab, 1);
rand_idxs = randperm(num_examples);
X_img = X_img(:,:,:,rand_idxs);
Y_lab = Y_lab(rand_idxs, 1);

nrof_train = round(test_train_ratio*num_examples);
% train set
X = X_img(:,:,:,1:nrof_train);
Y = Y_lab(1:nrof_train,:);
%save('train_64x64.mat', 'X', 'Y'); %eurosat數據
save('train_256x256.mat', 'X', 'Y'); %ucm data

% test set
X = X_img(:,:,:,nrof_train+1:end);
Y = Y_lab(nrof_train+1:end,:);
% save('test_64x64.mat', 'X', 'Y');
save('test_256x256.mat', 'X', 'Y');

增加这样的语句:强制更改图片到指定的大小:

img = imresize(img,[256,256]);%原来的ucmerced中airplane55.tif 256*253的大小,导致出了问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值